Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- #Include <Constants.au3>
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <EditConstants.au3>
- Opt('MustDeclareVars', 1)
- Opt('TrayMenuMode', 1)
- Dim $configurazione[8]
- Global $confiurazione, $mainPid
- Func Impostazioni()
- Local $msg, $btnok, $btnsalva, $btnannulla
- Global $proxy, $username, $password, $proxyr, $dest, $newport, $browser, $header, $configurazione
- GUICreate('Scemo Utilities', 275, 440) ; will create a dialog box that when displayed is centered
- GUISetState(@SW_SHOW) ; will display an empty dialog box
- ; Opzione: indirizzo Proxy
- GUICtrlCreateGroup('Proxy (indirizzo:porta)', 10, 5, 250, 50)
- $proxy = GUICtrlCreateInput($configurazione[0], 20, 25, 200, 20)
- GUICtrlSetTip(-1, 'Il Proxy locale a cui ci si deve connettere.')
- GUICtrlCreateGroup('', -99, -99, 1, 1) ;close group
- ; Opzione: Username e password proxy
- GUICtrlCreateGroup('Credenziali di accesso', 10, 60, 250, 50)
- $username = GUICtrlCreateInput($configurazione[1], 20, 80, 95, 20)
- GUICtrlSetTip(-1, 'Usename per il proxy (può essere lasciato vuoto)')
- $password = GUICtrlCreateInput($configurazione[2], 125, 80, 95, 20, $ES_PASSWORD)
- GUICtrlSetTip(-1, 'Password per il proxy')
- GUICtrlCreateGroup('', -99, -99, 1, 1)
- ; Opzione: indirizzo Proxy Secondario
- GUICtrlCreateGroup('Proxy Secondario (indirizzo:porta)', 10, 115, 250, 50)
- $proxyr = GUICtrlCreateInput($configurazione[3], 20, 135, 200, 20)
- GUICtrlSetTip(-1, 'Il Proxy remoto a cui ci si deve connettere.')
- GUICtrlCreateGroup('', -99, -99, 1, 1)
- ; Opzione: indirizzo di Destinazione
- GUICtrlCreateGroup('Destinazione (indirizzo:porta)', 10, 170, 250, 50)
- $dest = GUICtrlCreateInput($configurazione[4], 20, 190, 200, 20)
- GUICtrlSetTip(-1, 'La destinazione a cui ci si vuole connettere.')
- GUICtrlCreateGroup('', -99, -99, 1, 1)
- ; Opzione: nuova porta
- GUICtrlCreateGroup('Porta interna', 10, 225, 250, 50)
- $newport = GUICtrlCreateInput($configurazione[5], 20, 245, 200, 20, $ES_NUMBER)
- GUICtrlSetTip(-1, 'Porta a cui i programmi si devono connettere')
- GUICtrlCreateGroup('', -99, -99, 1, 1)
- ; Opzione: Browser
- GUICtrlCreateGroup('Header User-agent', 10, 280, 250, 50)
- $browser = GUICtrlCreateInput($configurazione[6], 20, 300, 200, 20)
- GUICtrlSetTip(-1, 'User-agent del browser con cui si vuole fingere di connettersi')
- GUICtrlCreateGroup('', -99, -99, 1, 1)
- ; Opzione: Header aggiuntivo
- GUICtrlCreateGroup('Header Aggiuntivo', 10, 335, 250, 50)
- $header = GUICtrlCreateInput($configurazione[7], 20, 355, 200, 20)
- GUICtrlSetTip(-1, 'Un qualsiasi header aggiuntivo da passare al server')
- GUICtrlCreateGroup('', -99, -99, 1, 1)
- $btnok = GUICtrlCreateButton('&Ok', 12, 395, 75)
- GUICtrlSetTip(-1, 'Connettiti usando queste informazioni')
- $btnsalva = GUICtrlCreateButton('&Salva', 98, 395, 75)
- GUICtrlSetTip(-1, 'Salva queste come impostazioni di default')
- $btnannulla = GUICtrlCreateButton('&Annulla', 183, 395, 75)
- GUICtrlSetTip(-1, 'Chiudi la finestra senza salvare')
- ; Run the GUI until the dialog is closed
- While 1
- $msg = GUIGetMsg()
- Switch Int($msg)
- Case $GUI_EVENT_CLOSE
- GUIDelete()
- ExitLoop
- Case $btnok
- Impostazioni_Configura()
- Chiudi_Proxytunnel()
- Avvia_Proxytunnel()
- GUIDelete()
- ExitLoop
- Case $btnsalva
- Impostazioni_Configura()
- Salva_Impostazioni()
- Case $btnannulla
- GUIDelete()
- ExitLoop
- EndSwitch
- WEnd
- EndFunc
- Func Impostazioni_Configura()
- Global $proxy, $username, $password, $proxyr, $dest, $newport, $browser, $header, $configurazione
- $configurazione[0]=GUICtrlRead($proxy)
- $configurazione[1]=GUICtrlRead($username)
- $configurazione[2]=GUICtrlRead($password)
- $configurazione[3]=GUICtrlRead($proxyr)
- $configurazione[4]=GUICtrlRead($dest)
- $configurazione[5]=GUICtrlRead($newport)
- $configurazione[6]=GUICtrlRead($browser)
- $configurazione[7]=GUICtrlRead($header)
- EndFunc
- Func Carica_Impostazioni()
- Global $configurazione
- Local $file
- $file='impostazioni.ini'
- $configurazione[0]=IniRead($file, 'Proxytunnel', 'proxy', '')
- $configurazione[1]=IniRead($file, 'Proxytunnel', 'username', '')
- $configurazione[2]=IniRead($file, 'Proxytunnel', 'password', '')
- $configurazione[3]=IniRead($file, 'Proxytunnel', 'proxyr', '')
- $configurazione[4]=IniRead($file, 'Proxytunnel', 'dest', '')
- $configurazione[5]=IniRead($file, 'Proxytunnel', 'newport', '46637')
- $configurazione[6]=IniRead($file, 'Proxytunnel', 'browser', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12')
- $configurazione[7]=IniRead($file, 'Proxytunnel', 'header', '')
- EndFunc
- Func Salva_Impostazioni()
- Global $configurazione
- Local $file
- $file='impostazioni.ini'
- IniWrite($file, 'Proxytunnel', 'proxy', $configurazione[0])
- IniWrite($file, 'Proxytunnel', 'username', $configurazione[1])
- IniWrite($file, 'Proxytunnel', 'password', $configurazione[2])
- IniWrite($file, 'Proxytunnel', 'proxyr', $configurazione[3])
- IniWrite($file, 'Proxytunnel', 'dest', $configurazione[4])
- IniWrite($file, 'Proxytunnel', 'newport', $configurazione[5])
- IniWrite($file, 'Proxytunnel', 'browser', $configurazione[6])
- IniWrite($file, 'Proxytunnel', 'header', $configurazione[7])
- EndFunc
- Func Avvia_Proxytunnel()
- Global $confiurazione, $mainPid
- Local $cmd
- $cmd='proxytunnel.exe -q -a ' & $configurazione[5] & ' -p ' & $configurazione[0] & ' -d ' & $configurazione[4]
- if $configurazione[1] <> '' AND $configurazione[2] <> '' Then
- $cmd=$cmd & ' -u ' & $configurazione[1] & ' -s ' & $configurazione[2]
- EndIf
- If $configurazione[3] <> '' Then
- $cmd=$cmd & ' -r ' & $configurazione[3]
- EndIf
- $cmd=$cmd & ' -H "' & StringReplace($configurazione[6], '"', '') & '"'
- If $configurazione[4] <> '' Then
- $cmd=$cmd & ' -H "' & StringReplace($configurazione[7], '"', '') & '"'
- EndIf
- $mainPid=Run($cmd, '', @SW_HIDE)
- If ProcessExists($mainPid) Then
- TrayTip('Proxytunnel', 'Proxytunnel è stato avviato', 5)
- Auto_Firewall()
- return 1
- Else
- TrayTip('Proxytunnel', 'Non è stato possibile avviare ProxyTunnel', 5)
- return 0
- EndIf
- EndFunc
- Func Chiudi_Proxytunnel()
- Global $mainPid
- Local $list
- ProcessClose($mainPid)
- $list=ProcessList('proxytunnel.exe')
- for $i = 1 to $list[0][0]
- ProcessClose($list[$i][0])
- next
- TrayTip('Proxytunnel', 'Proxytunnel è stato chiuso', 5)
- EndFunc
- Func Auto_Firewall()
- Local $list
- Sleep(400)
- WinActivate('Avviso di protezione Windows') ; Windows Firewall ;-)
- $list=WinList('Avviso di protezione Windows')
- If $list[0][0]>0 Then
- Send('{TAB}')
- Send('{TAB}')
- Send('{TAB}')
- Send('{TAB}')
- Send('{TAB}')
- Send('{ENTER}')
- EndIf
- EndFunc
- Carica_Impostazioni()
- Local $status_tray, $prefsitem, $aboutitem, $exititem, $msg
- $status_tray=TrayCreateItem('Proxytunnel avviato')
- TrayItemSetState($status_tray, 0)
- TrayCreateItem('')
- $prefsitem=TrayCreateItem('Impostazioni')
- TrayCreateItem('')
- $aboutitem=TrayCreateItem('About')
- $exititem=TrayCreateItem('Esci')
- TraySetState()
- TraySetToolTip('Proxytunnel')
- If Avvia_Proxytunnel()=1 Then
- TrayItemSetState($status_tray, ($TRAY_CHECKED+$TRAY_ENABLE))
- OnAutoItExitRegister('Chiudi_Proxytunnel')
- Else
- TrayItemSetState($status_tray, $TRAY_ENABLE+$TRAY_UNCHECKED)
- TrayItemSetText($status_tray, 'Proxytunnel chiuso')
- EndIf
- While 1
- $msg = TrayGetMsg()
- Select
- Case $msg=0
- ContinueLoop
- Case $msg=$status_tray
- If (($TRAY_ENABLE+$TRAY_UNCHECKED)=TrayItemGetState($status_tray)) Then
- Chiudi_Proxytunnel()
- TrayItemSetState($status_tray, $TRAY_ENABLE+$TRAY_UNCHECKED)
- TrayItemSetText($status_tray, 'Proxytunnel chiuso')
- Else
- If Avvia_Proxytunnel()=1 Then
- TrayItemSetState($status_tray, $TRAY_ENABLE+$TRAY_CHECKED)
- TrayItemSetText($status_tray,'Proxytunnel avviato')
- Else
- TrayItemSetState($status_tray, $TRAY_ENABLE+$TRAY_UNCHECKED)
- TrayItemSetText($status_tray, 'Proxytunnel chiuso')
- EndIf
- EndIf
- ContinueLoop
- Case $msg=$prefsitem
- Impostazioni()
- TrayItemSetState($prefsitem, $TRAY_UNCHECKED)
- ContinueLoop
- Case $msg=$aboutitem
- TrayItemSetState($aboutitem, $TRAY_UNCHECKED)
- Msgbox(64, 'About', 'Proxytunnel GUI. Powered by Piero VDFN')
- ContinueLoop
- Case $msg=$exititem
- TrayItemSetState($exititem, $TRAY_UNCHECKED)
- Exit
- ExitLoop
- EndSelect
- WEnd
- Exit
Advertisement
Add Comment
Please, Sign In to add comment