Renderer Posted April 12, 2017 Posted April 12, 2017 Hello there! Is there any posibility to connect to a wifi network via AutoIt? Is there any COM Object able to do that? Thanks in advance.
Moderators JLogan3o13 Posted April 12, 2017 Moderators Posted April 12, 2017 yes, you can use netsh, look at the connect command: https://technet.microsoft.com/en-us/library/cc755301(v=ws.10).aspx "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Renderer Posted April 13, 2017 Author Posted April 13, 2017 (edited) On 4/12/2017 at 8:44 PM, JLogan3o13 said: yes, you can use netsh, look at the connect command: https://technet.microsoft.com/en-us/library/cc755301(v=ws.10).aspx Expand I think this command only allows me to connect to the networks i've got in the "Manage Wireless Networks" list. I can't connect to different wifi networks, that require a password. Edited April 13, 2017 by Renderer
Moderators JLogan3o13 Posted April 13, 2017 Moderators Posted April 13, 2017 Apologies, you stated "connect to wifi"; didn't realize you were after connecting to a new network, passing SSID, password, etc. The only way I have accomplished this is when doing it for a large number of machines: you configure it once manually, then export the config with netsh, then import on all your other machines. It doesn't sound like that is what you are after, however. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Renderer Posted April 13, 2017 Author Posted April 13, 2017 On 4/13/2017 at 1:32 PM, JLogan3o13 said: Apologies, you stated "connect to wifi"; didn't realize you were after connecting to a new network, passing SSID, password, etc. The only way I have accomplished this is when doing it for a large number of machines: you configure it once manually, then export the config with netsh, then import on all your other machines. It doesn't sound like that is what you are after, however. Expand Let's assume i've got a new network on my list,that is not mine. Does your advices apply on this situation too? And let's assume i know the password too. How do i connect to the new network i've just discovered,with the given data (network name and password). Thanks for your previous answers.
Moderators JLogan3o13 Posted April 13, 2017 Moderators Posted April 13, 2017 Again, the only way I know of doing it is to do so manually, then export the wifi profile using netsh. If you are looking to do it on only one device, however, that doesn't help you much. The only other option would be an attempt to manipulate the Manage Wireless Networks control panel item, which I have never had need to do, personally. Someone else may wander along with other suggestions. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Nikolas92 Posted April 13, 2017 Posted April 13, 2017 (edited) Maybe you can use this: https://www.symantec.com/connect/articles/how-capture-and-deploy-wlan-profiles https://support.arubanetworks.com/ToolsResources/tabid/76/EntryId/109/DMXModule/514/Default.aspx https://sourceforge.net/projects/wirelessscanner/ Edited April 13, 2017 by Nikolas92
Moderators JLogan3o13 Posted April 13, 2017 Moderators Posted April 13, 2017 The first link does precisely what I am suggesting to do natively, connects through an existing (exported) profile. The sourceforge project states it can only connect if there is no authentication (open network). I am unfamiliar with the arubnetworks tool, but am hesitant on any application that is so undocumented. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Belini Posted March 23, 2018 Posted March 23, 2018 @Renderer I also need to connect on different wifi networks that ask password to connect, did you get to do this? Can you give hint how to create a new profile to connect? My Codes: Reveal hidden contents Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Reveal hidden contents Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Moderators JLogan3o13 Posted March 23, 2018 Moderators Posted March 23, 2018 Here's another link that shows how to do it, although it contains the same information as the other links you've been provided... https://stackoverflow.com/questions/35232162/add-wifi-profile-with-password-in-windows-programmatically "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Bilgus Posted March 23, 2018 Posted March 23, 2018 So I looked at the links using netsh wlan export profile key=clear in a cmd prompt as admin.. it was easy to get an xml file here is a simple reproduction for you Note that the tabs aren't needed and you can probably use Execute() to make it cleaner but you get the idea Local $Wifi_Name = "Wifi_network" Local $Wifi_Auth = "WPAPSK" Local $Wifi_Encrypt = "AES" Local $Wifi_KeyType = "passPhrase" Local $Wifi_Pass = "123456" Local $Wifi_Xml = _ '<?xml version="1.0"?>' & @CRLF & _ '<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">' & @CRLF & _ @Tab & '<name>' & $Wifi_Name & '</name>'& @CRLF & _ @Tab & '<SSIDConfig>'& @CRLF & @Tab & @TAB & '<SSID>' & @CRLF & _ @Tab &@Tab & @Tab & '<hex>' & StringTrimLeft(StringToBinary($Wifi_Name), 2) & '</hex>' & @CRLF & _ @Tab &@Tab & @Tab & '<name>' & $Wifi_Name& '</name>'& @CRLF &@Tab & @TAB & '</SSID>'& @CRLF & _ @Tab & '</SSIDConfig>'& @CRLF & _ @Tab & '<connectionType>ESS</connectionType>'& @CRLF & _ @Tab & '<connectionMode>auto</connectionMode>'& @CRLF & _ @Tab & '<MSM>'& @CRLF & @Tab & @TAB & '<security>'& @CRLF & @Tab & @Tab & @TAB & '<authEncryption>'& @CRLF & _ @Tab &@Tab & @Tab & @TAB & '<authentication>'& $Wifi_Auth & '</authentication>'& @CRLF & _ @Tab &@Tab & @Tab & @TAB & '<encryption>' & $Wifi_Encrypt & '</encryption>'& @CRLF & _ @Tab &@Tab & @Tab & @TAB & '<useOneX>false</useOneX>'& @CRLF & @Tab & @Tab & @TAB & '</authEncryption>' & @CRLF & _ @Tab & @Tab & @TAB & '<sharedKey>'& @CRLF & _ @Tab &@Tab & @Tab & @Tab &'<keyType>' & $Wifi_KeyType & '</keyType>'& @CRLF & _ @Tab &@Tab & @Tab & @Tab &'<protected>false</protected>'& @CRLF & _ @Tab &@Tab & @Tab & @Tab &'<keyMaterial>' & $Wifi_Pass & '</keyMaterial>'& @CRLF & _ @Tab & @Tab & @Tab &'</sharedKey>'& @CRLF &@Tab & @Tab &'</security>'& @CRLF & @Tab & '</MSM>'& @CRLF & _ '</WLANProfile>' ;;;; consoleWrite($Wifi_Xml)
Belini Posted March 23, 2018 Posted March 23, 2018 (edited) @Bilgus with your example I was able to see how to get the hex value but still need to know how to get the keymaterial encrypted because it does not accept to put the key as it is! EDIT: @Bilgus the .xml in the way you created it did not work, I created it another way and it worked, now I just have to be able to encrypt the keymaterial so I can create a new profile from the network name and password! Script to create a new profile expandcollapse popupLocal $name = "Algar" Local $connectionType = "ESS" Local $connectionMode = "auto" Local $authentication = "WPAPSK" Local $encryption = "AES" Local $useOneX = "false" Local $keyType = "passPhrase" Local $protected = "true" Local $keyMaterial = "01000000D08C9DDF0115D1118C7A00C04FC297EB01000000ABDCD6E3A4830D49AC271E6CF601A57F000000000200000000001066000000010000200000001AD5A2710D171BC7E630E643FDC673762CF3D841465D1510296CFC1E86E848FA000000000E80000000020000200000003593137CBDC0E2E5835904DEB9CB8EFE448C854AA0F1E886A26578BC6919477910000000F0F3C7B8F260245B02AA7944B1A7397540000000E20FB924B105B40B2CB570E2B6921E55DCDBD6DDC375C192B1D739658C61ECD3EBA58214DE35A57C23D9B6F31A83705A0253284EE5AD122BE5CE63B324BB416A" Local $Wifi_Xml = '<?xml version="1.0"?>' & @CRLF & _ '<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">' & @CRLF & _ ' <name>' & $name & '</name>' & @CRLF & _ ' <SSIDConfig>' & @CRLF & _ ' <SSID>' & @CRLF & _ ' <hex>' & StringTrimLeft(StringToBinary($name), 2) & '</hex>' & @CRLF & _ ' <name>' & $name & '</name>' & @CRLF & _ ' </SSID>' & @CRLF & _ ' </SSIDConfig>' & @CRLF & _ ' <connectionType>' & $connectionType & '</connectionType>' & @CRLF & _ ' <connectionMode>' & $connectionMode & '</connectionMode>' & @CRLF & _ ' <MSM>' & @CRLF & _ ' <security>' & @CRLF & _ ' <authEncryption>' & @CRLF & _ ' <authentication>' & $authentication & '</authentication>' & @CRLF & _ ' <encryption>' & $encryption & '</encryption>' & @CRLF & _ ' <useOneX>' & $useOneX & '</useOneX>' & @CRLF & _ ' </authEncryption>' & @CRLF & _ ' <sharedKey>' & @CRLF & _ ' <keyType>' & $keyType & '</keyType>' & @CRLF & _ ' <protected>' & $protected & '</protected>' & @CRLF & _ ' <keyMaterial>' & $keyMaterial & '</keyMaterial>' & @CRLF & _ ' </sharedKey>' & @CRLF & _ ' </security>' & @CRLF & _ ' </MSM>' & @CRLF & _ '</WLANProfile>' ConsoleWrite($Wifi_Xml & @CRLF) FileWrite(@ScriptDir & "\" & $name & ".xml", $Wifi_Xml) With this script I can connect to the profile that was created expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <nativewifi.au3> ;#include <Array.au3> Global $Cb_rede, $Inp_pass, $But_refresh, $But_connect, $sreason _Wlan_StartSession(); inicia a sessão ;_wlan_deleteprofile("Algar"); deleta um perfil Gui() ;$scan = _Wlan_GetNetworks(True) ;_ArrayDisplay($scan) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $But_refresh update_combo() Case $But_connect $rede = GUICtrlRead($Cb_rede) _wlan_setprofile(fileread(@ScriptDir & "\" & $rede & ".xml"), $sreason); importa um perfil _Wlan_Connect($rede, True); conecta a um perfil EndSwitch WEnd Func Gui() GUICreate("Wifi connection", 434, 104, -1, -1) GUICtrlCreateLabel("Rede wifi:", 8, 20, 51, 17) GUICtrlCreateLabel("Password:", 253, 20, 53, 17) $Cb_rede = GUICtrlCreateCombo("Choose a network", 64, 16, 169, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) update_combo() $Inp_pass = GUICtrlCreateInput("", 312, 16, 113, 21, BitOR($ES_PASSWORD, $ES_CENTER, $ES_NUMBER)) $But_refresh = GUICtrlCreateButton("Refresh", 40, 64, 139, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $But_connect = GUICtrlCreateButton("Connect", 246, 64, 139, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetState($But_connect, $GUI_FOCUS) GUISetState(@SW_SHOW) EndFunc ;==>Gui Func update_combo() Local $data = "", $scan = "" GUICtrlSetData($Cb_rede, "") $scan = _Wlan_GetNetworks(True) $avaiable = UBound($scan) - 1 If $avaiable > 0 Then For $i = 0 To $avaiable $data &= $scan[$i][1] & "|" Next GUICtrlSetData($Cb_rede, $data, $scan[0][0]) EndIf EndFunc ;==>update_combo Does anyone know how I can encrypt the password for keymaterial? Edited March 23, 2018 by Belini My Codes: Reveal hidden contents Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Reveal hidden contents Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Bilgus Posted March 23, 2018 Posted March 23, 2018 There is no such requirement that I see at least for all the WPA stuff I deleted my current test wifi network I then used netsh wlan add profile filename="s:\Wireless.xml" user=all It connected fine if you have to have the key encrypted then we are back to make connect the network manually and save the xml You might also check by generating a new xml on your machine after creating the connection manually (don't forget key=clear) and see if they match Other than this I don't know what to tell you
Earthshine Posted March 23, 2018 Posted March 23, 2018 He likes exclamation marks! My resources are limited. You must ask the right questions
Belini Posted March 23, 2018 Posted March 23, 2018 On 3/23/2018 at 6:53 PM, Bilgus said: There is no such requirement that I see at least for all the WPA stuff I deleted my current test wifi network I then used netsh wlan add profile filename="s:\Wireless.xml" user=all It connected fine if you have to have the key encrypted then we are back to make connect the network manually and save the xml You might also check by generating a new xml on your machine after creating the connection manually (don't forget key=clear) and see if they match Other than this I don't know what to tell you Expand I can not create a profile manually because my program will be open all the time and the user will not have the taskbar, desktop, explorer and manager on.I will put notebooks at commercial points and at each point I will find a different wifi network and with its own password there will give the user access only to choose the network, enter the password and connect. My Codes: Reveal hidden contents Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Reveal hidden contents Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
AdamUL Posted March 23, 2018 Posted March 23, 2018 Maybe this will be helpful. I am currently unable to play around with it. https://www.purehacking.com/blog/vitaly-nikolenko/extracting-wireless-wep/wpa/wpa2-preshared-keys/passwords-from-windows-7 Here is a UDF for some of the functions mentioned. Adam
Belini Posted March 24, 2018 Posted March 24, 2018 (edited) In this case you have the key to do the decryption and what I need is the opposite that would be to encrypt the password to put in keymaterial, maybe what I want is neither possible and only windows can encrypt the password stored in keymaterial. EDIT: I think that in this way I will not be able to achieve this, I'm looking for other alternative here Edited March 24, 2018 by Belini My Codes: Reveal hidden contents Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Reveal hidden contents Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now