Jump to content

Send any file over TCP


jvanegmond
 Share

Recommended Posts

Where does convert.exe for neet?

I've got an error if I will open it:

Line 0 (File "C:\..\..\convert.exe");

$File=$Cmdline[1]
$File=^ERROR 

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.
Edited by YoseMite
Link to comment
Share on other sites

Sorry, i forgot to post the script that's in the exe. I will do this later. The exe converts REPNULL back to a Chr(0). You have to run the .exe with a parameter which contains the file to convert. So if you want to a convert a file back to the original (the script does this too once's it's completed.) you have to run:

Convert.exe "C:\File to convert.jpg"

I hope this makes sence to you.

Edited by Manadar
Link to comment
Share on other sites

:) i've follow error:

Website gesperrt!

G DATA AntiVirenKit hat den Zugriff auf diese Webseite verweigert.

Die Seite enthält infizierten Code: Trojan.Downloader.Agent.PG.

in English:

Website closed! G DATA anti-virus kits refused the access to this web page. The side contains infected code: Trojan.Downloader.Agent.PG.

*bg* i've written self a FileOverTCP Programm look here:

http://autoit.aufwaerts.de/thread.php?threadid=414

When desired i can post it here, too!

www.AutoIt.de - Moderator of the German AutoIt Forum

 

Link to comment
Share on other sites

have you seen the one i made?

you can find it in my signature.

Arjan

Link to comment
Share on other sites

I have taken out the need for convert.exe by using the fantastic coroutine UDF Coroutine.au3Here is the modified share client Share_Client.au3 Note: not tested because it doesnt work on my comp (i think because i am on a LAN)

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Razer, TCP functionallity in autoit can work over lan because i'm behind a router and i can set up a server etc. just by forwarding the proper port. Anyway, i will look forward into studying this coroutine udf you included.

GtaSpider, unfortunately my knowdledge of german is very limited and i can't really understand the posts you have made in your link. However, if you could explain to me what your script or idea's can help my script. That will be very welcome. However, i'd like to know, you must have had issues sending a 0 Character? How did you resolve this?

arjan staring, in your topic i noticed that someone posted this:

If you sent an exe, wouldn't it hang on any Chr(0)'s?

The answer to this is yes, Most files are actually full of Chr(0) and you can Not TCP Send a 0 character. So that's the reason why i have actually scripted this, now being abled to send 0 characters (in Scite those appear as black blocks [NUL]) you can send ANY file over the inet.

Also, arjan staring, try sending testimage.jpg included in this rar file with your script. You will notice graphical corruption in the image, or you may not be abled to open it.

Edited by Manadar
Link to comment
Share on other sites

but does the script i provided work Manadar (Share Client.au3) i have already modified it to use the coroutine UDF

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

but does the script i provided work Manadar (Share Client.au3) i have already modified it to use the coroutine UDF

I didn't have the script on this PC anymore so i was forced to redownload it. that's the reason why i wanted to wait in the first place.

other then that autoit required me to define $convert it didn't work at all.

First line from the sent testfile.jpg

ÿØÿàREPNULLJFIFREPNULLREPNULLREPNULLdREPNULLdREPNULLREPNULLÿìREPNULLDuckyREPNULL

You can see the REPNULL has not been replaced. This may be due to that you forgot to define $file in the extra file you are writing?

[Edit] The unexpected number of posts and interest in this subject has led me to believe there is no fixed solution. I will now try to build a good FileSend function/script in the next days.

Edited by Manadar
Link to comment
Share on other sites

I made a quick test using

#include <coroutine.au3>
$File = "C:\test.txt"
$convert = _CoCreate('Func Convert($File)||$Filehdl = FileOpen($File, 0)||$Data = FileRead($Filehdl)||FileClose($Filehdl)||$Filehdl = FileOpen($File, 2)|FileWrite($Filehdl,StringReplace($Data, "REPNULL", Chr(0), 0, 1 ) )|FileClose($Filehdl)|Return 1|EndFunc')
_CoStart($convert, "$File")
with the code you posted above (when REPNULL wans't replaced) and it worked

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

So wait a sec...Is filesending a problem over TCP? I have written a script that does this fine i think...i don't remember having an issue with this Chr(0) thing...I'll check it later as I don't have the source on me ATM...but would it be anything special? I thought i've already seen other scripts so this also...

Link to comment
Share on other sites

OK so here's the excerpt from a script I wrote--

Senders code-

$filetosend=FileOpenDialog ("Select the file to send",@DesktopDir, "All Files (*.*)")
if $filetosend="" then Return
TrayTip("Connection to " & $fileipto & " established","Asking to send file... ",5)
$fsize= FileGetSize($filetosend)
TCPSend($fileconsock, $filelocalhost & "?" & $filetosend & "?" & $fsize)
While 1
    $YesNo = TCPRecv($fileconsock,10)
    If $YesNo = "Yes" Then ExitLoop
    If $YesNo = "No" Then 
        MsgBox(0,"Request Denied",$fileipto & " has denied your file send request")
        Return
    EndIf
WEnd
TrayTip("Loading file to TCP Buffer","",15)
If $fsize>1000000000 Then
    MsgBox(0,"Error: Internal","File sizes greater than 100 MB are currently not suported")
    Return
EndIf
$tosend=FileRead($filetosend,$fsize)
$check=TCPSend($fileconsock,$tosend)
If $check <> $fsize Then MsgBox(0,"Error: " & @error,"Error Sending File") 
TrayTip("Done","Host can download file...",15)
oÝ÷ ٩ݶ«yȽêìjëh×6
While 1
    $cleintIp = TCPRecv($fileosocket, 512)
    If $cleintIp <> "" Then 
        $cleintIp = StringSplit ($cleintIP, "?")
        $a = MsgBox(4,"File Request",$cleintIp[1] & " wants to send you " & $cleintIp[2] & ". Accept file?")
        If $a = 7 Then 
            TCPSend ($fileosocket,"No")
            ExitLoop
        EndIf
        If $a = 6 Then
            dim $incomming
            ProgressOn("Recieving File: " & $cleintIP[2] ,"time:","Received - ","","",18)
            $filetype=StringRight($fcleintIp[2],5)
            if stringleft($filetype,1)<>"." Then $filetype=stringright($filetype,3)
            $save=FileSaveDialog ("Save file to where",@DesktopDir,$filetype & " (*." & $filetype & ")")
            $fpath = $save & "." & $filetype    
            $save = FileOpen($fpath,1)
            $total=0
            Do 
                $flush=TCPRecv($fileosocket,$filepacketsize)
                $total = $total +1
            Until $total=3
            TCPSend($fileosocket,"Yes")
            $timmer=TimerInit()
            $updater=25
            While 1
                $incomming = TCPRecv ($fileosocket,$filepacketsize)
                $hex=string($incomming)
                if $hex<>"" then
                    FileWrite($save,$incomming)
                    $total= $total + StringLen($hex)/2
                    $updater=$updater-1
                    if $updater=0 then
                        ProgressSet($total/$cleintIP[3]*100,Round (($total/1024)/(TimerDiff($timmer)/1000),1) & "KBs/Sec",Round($total/1024,1)  & "KB of " & Round($cleintIP[3]/1024,1))
                        $updater=25
                    EndIf
                EndIf
                if $total >= $cleintIP[3] then exitloop
            Wend 
            FileClose($save)
            ProgressOff()
            MsgBox(0,"File's Done", "Recived File: " & $fpath)
            ExitLoop
        EndIf
    EndIf
WEnd

Of course the 100MB limit is just becuase the TCP buffer is 128MB (I think?) but it can be worked around by splitting the file into smaller peices first.

And of course this code wont compile becuase it's just a snippet... but anyways I don't think i ever had any problems with it...that chr(0) thing doesnt' make sense to me...

Edit: Hey BTW how do you make your code color-highlighted after you post it?

Edit2: OOO pretty..Thanks Razer

Edited by evilertoaster
Link to comment
Share on other sites

use [ autoit] code here [ /autoit] tags without the spaces

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Ok, tell me if I have this right.

The function won't work because the null charectar (Asc( 0 ) ) wont be accepted through the TCPSend function.

If that is right wouldn't it be a simple matter of Using a func like:

Func _StringReplaceAllNullsAndSend( $string )
   $string = StringBreak( $string )
   For $i = 0 To StringLen( $string[0] )
      If $string[$i] = Asc( 0 ) Then $string[$i] = "NULL CHARECTER"
   Next
   _SendStringOverTCP( $string )
EndFunc
oÝ÷ Ùh­§îËh­ç"z÷­ë-®)àjwcºË]¢Ø^¢h²+^jëh×6
Func _StringReturnAllNullsAndSend( $string )
   $string = StringBreak( $string )
   For $i = 0 To StringLen( $string[0] )
      If $string[$i] = "NULL CHARECTER" Then $string[$i] = Asc( 0 ) 
   Next
   Return _ArrayCombine( $string )
EndFunc

Now could someone please explain to me why these wouldn't work?

P.S. The funcs _StringBreak( ) and _ArrayCombine( ) are funcs I have on my comp. _stringBreak( ) Turns a string into into an array with array dimension 0 saying how many letters there are and the others having one letter in each so _StringBreak( "Hello" ) Would turn out like

$array[0] = 5

1 = H

2 = e

3 = l

4 = l

5 = o

and _ArrayCombine just does the exact opposite.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

  • 1 month later...

Ok, tell me if I have this right.

The function won't work because the null charectar (Asc( 0 ) ) wont be accepted through the TCPSend function.

If that is right wouldn't it be a simple matter of Using a func like:

Func _StringReplaceAllNullsAndSend( $string )
   $string = StringBreak( $string )
   For $i = 0 To StringLen( $string[0] )
      If $string[$i] = Asc( 0 ) Then $string[$i] = "NULL CHARECTER"
   Next
   _SendStringOverTCP( $string )
EndFunc
oÝ÷ Ùh­§îËh­ç"z÷­ë-®)àjwcºË]¢Ø^¢h²+^jëh×6
Func _StringReturnAllNullsAndSend( $string )
   $string = StringBreak( $string )
   For $i = 0 To StringLen( $string[0] )
      If $string[$i] = "NULL CHARECTER" Then $string[$i] = Asc( 0 ) 
   Next
   Return _ArrayCombine( $string )
EndFunc

Now could someone please explain to me why these wouldn't work?

P.S. The funcs _StringBreak( ) and _ArrayCombine( ) are funcs I have on my comp. _stringBreak( ) Turns a string into into an array with array dimension 0 saying how many letters there are and the others having one letter in each so _StringBreak( "Hello" ) Would turn out like

$array[0] = 5

1 = H

2 = e

3 = l

4 = l

5 = o

and _ArrayCombine just does the exact opposite.

What's wrong with StringReplace?

StringReplace($string,Chr(0),"NULL CHARACTER")

Done! The extra .exe is in there because if the sender starts immediately to another file, the whatsitcalled.exe then does the reverse stringreplace.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...