I'm looking for a python program that could detect when device has connected to a local wifi and start a specific program. And would communicate via SMS with raspberry pi.
Your question is too vague to be answered in full.
Why do you need python to check if a device connected? Shellscript would be much faster and waste less memory. Also, wich network are you monitoring?
Does the pi hang in an existing wlan, or does it provide a local hotspot?
If you want to check into an existing network, you could modify a python portscanner to look for devices instead of ports, but I won't code it for you, sry mate. Or did I get you wrong, and the python script shall be running on a laptop, because
Why would you send a sms to your raspberry? This assumes that the python script would not run on the raspberry itself. If you want to know how to send sms, GSM module is what you need
To me, this question looks really fishy. I am not helping you to build a assasination bomb device. At least not until you'd pay me 10 k ^^