Jump to content

ChristophX086

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by ChristophX086

  1. The example for the function Dec() is wrong. Local $bDec = Dec("FFF") MsgBox(4096, "", $bDec) ; Displays the number 65535. (FFF)16 = (4095)10 (FFFF)16 = (65535)10 Also, doesn't the prefix b mean the variable contains binary data? If it does, it should be changed to $iDec.
  2. Could you do the same thing with movie dvds and .mpeg files?
  3. Thanks, just uploaded Version 2. No comments? Just post what you think about it.
  4. Thanks hyperzap for your good answer. @trancexx No, not really.
  5. Very good work, trancexx. Could this also work with non-Pe-Format programs, like .com files coded in Assembly?
  6. Hi, Some time ago I made a script to forward TCP packets. The idea is something like: You ---> ForwardingServer ---> real Server ---> ForwardingServer ---> You instead of: You ---> real Server ---> You Here is Version 2.0: Changes: - now with GUI - UDP support - sending the data as it receives it Could be a bit buggy, but it works. to Do: - make use of the replace function (not very hard, just too lazy now) #NoTrayIcon #include <INet.au3> $Gui1 = GUICreate('', 300, 200) $g1Binary = GUICtrlCreateInput('Binary', 20, 20, 260, 20) $g1String = GUICtrlCreateEdit('String', 20, 50, 260, 100) $g1ToBinary = GUICtrlCreateButton('StringToBinary', 20, 160, 125, 20) $g1ToString = GUICtrlCreateButton('BinaryToString', 150, 160, 125, 20) GUISetState(@SW_SHOW, $Gui1) AdlibRegister('Title1', 500) TCPStartup() UDPStartup() Global $Pipe = -1, $Client = -1, $Server = -1, $PipeStarted = False Global $PipeIPAddress = @IPAddress1, $PipeIsTCP = True, $PipeProtocol = 'TCP', $PipePort = 80 Global $ServerIPAddress = @IPAddress1, $ServerIsTcp = True, $ServerProtocol = 'TCP', $ServerPort = 80 Global $i = 0, $Title1 = 'Binary To String', $i1 = 0 $Gui2 = GUICreate('', 300, 300) $g2PipeIPAddress = GUICtrlCreateInput($PipeIPAddress, 20, 20, 120, 20) GUICtrlSetTip($g2PipeIPAddress, 'The IP Address of the Pipe.', 'Help', 1, 1) $g2PipeProtocol = GUICtrlCreateCombo('TCP', 150, 20, 60, 20, 0x0003) GUICtrlSetData($g2PipeProtocol, 'UDP') GUICtrlSetTip($g2PipeProtocol, 'The Protocol of the Pipe.', 'Help', 1, 1) $g2PipePort = GUICtrlCreateInput($PipePort, 220, 20, 60, 20, 0x2000) GUICtrlSetTip($g2PipePort, 'The Port of the Pipe.', 'Help', 1, 1) $g2ServerIPAddress = GUICtrlCreateInput($ServerIPAddress, 20, 50, 120, 20) GUICtrlSetTip($g2ServerIPAddress, 'The IP Address of the Server.', 'Help', 1, 1) $g2ServerProtocol = GUICtrlCreateCombo('TCP', 150, 50, 60, 20, 0x0003) GUICtrlSetData($g2ServerProtocol, 'UDP') GUICtrlSetTip($g2ServerProtocol, 'The Protocol of the Server.', 'Help', 1, 1) $g2ServerPort = GUICtrlCreateInput($ServerPort, 220, 50, 60, 20, 0x2000) GUICtrlSetTip($g2ServerPort, 'The Port of the Server.', 'Help', 1, 1) $g2ReplaceRules = GUICtrlCreateEdit('', 20, 80, 260, 60, 20) GUICtrlSetTip($g2ReplaceRules, 'The Edit Control where you can define how the Packets should be modified.' & @CRLF _ & '[The Binary Data you want to replace];[The Binary Data you want to replace it with]' & @CRLF _ & '[The Binary Data you want to replace];[The Binary Data you want to replace it with]' & @CRLF _ & '...', 'Help', 1, 1) $g2StartStop = GUICtrlCreateButton('Start Pipe', 20, 150, 125, 20) $g2Exit = GUICtrlCreateButton('Exit', 155, 150, 125, 20) $g2Log = GUICtrlCreateEdit('', 20, 180, 260, 100) GUICtrlSetTip($g2Log, 'The Edit Control where all the Packets are being logged.', 'Help', 1, 1) GUISetState(@SW_SHOW, $Gui2) AdlibRegister('Title', 500) Do If $PipeStarted Then If $PipeIsTCP And $Client > 0 Then If $Server > 0 Then $clientip = SocketToIP($Client) $clientname = _TCPIpToName($clientip) $clientping = Ping($clientip) $received = TCPRecv($Client, 1024) If $received <> '' Then _AddToLog(_Time(2) & ' ' & $clientip & ' (Client) > ' & $ServerIPAddress & ' (Server):' & @CRLF & StringToBinary($received) & @CRLF) If $ServerIsTCP Then TCPSend($Server, $received) If @error Then $Server = -1 Else $received = TCPRecv($Server, 1024) EndIf Else UDPSend($Server, $received) If @error Then $Server = -1 Else $received = UDPRecv($Server, 1024) EndIf EndIf TCPSend($Client, $received) If @error Then $Client = -1 TCPCloseSocket($Server) $Server = -1 Else _AddToLog(_Time(2) & ' ' & $ServerIPAddress & ' (Server) > ' & $clientip & ' (Client):' & @CRLF & StringToBinary($received) & @CRLF) EndIf EndIf Else If $ServerIsTCP Then $Server = TCPConnect($ServerIPAddress, $ServerPort) Else $Server = UDPOpen($ServerIPAddress, $ServerPort) EndIf If @error Then $Server = -1 EndIf EndIf ElseIf $PipeIsTCP = False Then If $Client > 0 Then $received = UDPRecv($Pipe, 1024) If $received <> '' Then _AddToLog(_Time(2) & ' ???.???.???.??? (Client) > ' & $ServerIPAddress & ' (Server):' & @CRLF & StringToBinary($received) & @CRLF) If $ServerIsTCP Then TCPSend($Server, $received) If @error Then $Client = -1 Else $received = TCPRecv($Server, 1024) EndIf Else UDPSend($Server, $received) If @error Then $Client = -1 Else $received = UDPRecv($Server, 1024) EndIf EndIf UDPSend($Pipe, $received) _AddToLog(_Time(2) & ' ' & $ServerIPAddress & ' (Server) > ???.???.???.??? (Client):' & @CRLF & StringToBinary($received) & @CRLF) EndIf Else If $ServerIsTCP Then $Server = TCPConnect($ServerIPAddress, $ServerPort) Else $Server = UDPOpen($ServerIPAddress, $ServerPort) EndIf If @error Then $Server = -1 Else $Client = 1 EndIf EndIf Else If $PipeIsTCP Then $Client = TCPAccept($Pipe) EndIf EndIf EndIf $Msg = GUIGetMsg() If $Msg = $g1ToBinary Then GUICtrlSetData($g1Binary, StringToBinary(GUICtrlRead($g1String))) EndIf If $Msg = $g1ToString Then GUICtrlSetData($g1String, BinaryToString(GUICtrlRead($g1Binary))) EndIf If $Msg = $g2StartStop Then If $PipeStarted Then If $PipeIsTCP Then TCPCloseSocket($Client) $Client = -1 TCPCloseSocket($Pipe) $Pipe = -1 Else UDPCloseSocket($Pipe) EndIf If $ServerIsTCP Then TCPCloseSocket($Server) $Server = -1 Else UDPCloseSocket($Server) $Server = -1 EndIf $PipeStarted = False GUICtrlSetData($g2StartStop, 'Start Pipe') Else $PipeIPAddress = GUICtrlRead($g2PipeIPAddress) $PipeProtocol = GUICtrlRead($g2PipeProtocol) If $PipeProtocol = 'TCP' Then $PipeIsTCP = True ElseIf $PipeProtocol = 'UDP' Then $PipeIsTCP = False Else ; LOL... Easter Egg... This part should never be run. Let's use TCP. $PipeIsTCP = True EndIf $ServerPort = GUICtrlRead($g2ServerPort) $ServerIPAddress = GUICtrlRead($g2ServerIPAddress) $ServerProtocol = GUICtrlRead($g2ServerProtocol) If $ServerProtocol = 'TCP' Then $ServerIsTCP = True ElseIf $ServerProtocol = 'UDP' Then $ServerIsTCP = False Else ; LOL... Easter Egg... This part should never be run. Let's use TCP. $ServerIsTCP = True EndIf $ServerPort = GUICtrlRead($g2ServerPort) If $PipeIsTCP Then $Pipe = TCPListen($PipeIPAddress, $PipePort, 1) Else $Pipe = UDPBind($PipeIPAddress, $PipePort) EndIf If @error Then MsgBox(16, 'Error', 'Couldn''t start Pipe on IP Address "' & $PipeIPAddress & '" and Port ' & $PipePort & '.', 0, $Gui2) $PipeStarted = False Else $PipeStarted = True GUICtrlSetData($g2StartStop, 'Stop Pipe') EndIf EndIf EndIf Until $Msg = -3 Or $Msg = $g2Exit AdlibUnRegister('Title1') AdlibUnRegister('Title') If $PipeStarted Then If $PipeIsTCP Then TCPCloseSocket($Pipe) Else UDPCloseSocket($Pipe) EndIf EndIf TCPShutdown() UDPShutdown() Exit Func Title1() $Title = $Title1 $Len = StringLen($Title) $Title = StringLeft($Title, $i1) WinSetTitle($Gui1, '', $Title) $i1 += 1 If $i1 = ($Len + 1) Then $i1 = 0 If $Title1 = 'Binary To String' Then $Title1 = 'String To Binary' Else $Title1 = 'Binary To String' EndIf EndIf Return True EndFunc Func Title() $Title = 'ChristophX86 Packet Forwarding' $Len = StringLen($Title) $Title = StringLeft($Title, $i) WinSetTitle($Gui2, '', $Title) $i += 1 If $i = ($Len + 1) Then $i = 0 EndIf Return True EndFunc Func _AddToLog($Message) Global $g2Log Return GUICtrlSetData($g2Log, $Message & @CRLF, 'append') EndFunc ; Function Name: _Time ; Function Description: simple function to get the number of seconds since the start of the unix-epoch ; Function Author: ChristophX86 Func _Time($Mode=1) If $Mode = 1 Then Return ((@YEAR - 1970) * 86400*360) + (@YDAY * 86400) + (@HOUR * 3600) + (@MIN * 60) + @SEC ElseIf $Mode = 2 Then Return @MON & '/' & @MDAY & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC EndIf EndFunc ; Function to return IP Address from a connected socket. ;---------------------------------------------------------------------- Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP
  7. @smashly I think your idea is much better than mine, but I just wanted to share my idea. Anyway great script, I really like it.
  8. It would be possible to use LAME (http://lame.sourceforge.net/) to convert the .wav files to mp3. I would use the Run() command and the command line "lame [options] inputfile [outputfile]".
×
×
  • Create New...