Jump to content
Sign in to follow this  
beserk1

TCPrecv

Recommended Posts

beserk1

I am having trouble to use TCPrecv to download a file through HTTP.

This script suppose to send a packet to the server requesting a certain torrent file, and download it using tcprecv.

When it downloads, the null character will turn from a single NULL character into 4 character ("0x00") representing NULL instead.

is there anyway to prevent this from happening?

;http://www.keytrue.com/link.php?ref=UGFiRrYo1m
TCPStartUp()

$data = "UGFiRrYo1m"
$host = "97.74.181.1"
$time = TimerInit()

$sPost = "-----------------------------" & $time & @CRLF
$sPost &= "Content-Disposition: form-data; name=""ref""" & @CRLF & @CRLF
$sPost &= $data & @CRLF
$sPost &= "-----------------------------" & $time & "--" & @CRLF

$sPacket = "POST /download.php HTTP/1.1" & @CRLF
$sPacket &= "Host: www.keytrue.com" & @CRLF
$sPacket &= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100403 Firefox/3.6.3 (Palemoon/3.6.3) (.NET CLR 3.5.30729)" & @CRLF
$sPacket &= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @CRLF
$sPacket &= "Accept-Language: en-us,en;q=0.5" & @CRLF
$sPacket &= "Accept-Encoding: gzip,deflate" & @CRLF
$sPacket &= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @CRLF
$sPacket &= "Keep-Alive: 115" & @CRLF
$sPacket &= "Connection: keep-alive" & @CRLF
$sPacket &= "Referer: http://www.keytrue.com/link.php?ref=" & $data & @CRLF
$sPacket &= "Content-Type: multipart/form-data; boundary=---------------------------" & $time & @CRLF
$sPacket &= "Content-Length: " & StringLen($sPost) & @CRLF & @CRLF & $sPost

$iSocket = TCPConnect($host, 80 )
    
$iSend = TCPSend($iSocket, $sPacket)
    
While 1
    $sRecv = TCPRecv($iSocket, 1)
    If $sRecv <> '' Then
        While 1
            $sRecv &= TCPRecv($iSocket, 1)
            If @error Then ExitLoop 2
        WEnd
    EndIf
WEnd

$sName = "UGFiRrYo1m.org_3.0_for_Windows.4454006.TPB.torrent"
$sData = StringTrimLeft ( $sRecv, StringInStr ( $sRecv, "b3d1") + StringLen ( "b3d1" ) )

$fTemp = FileOpen ( $sName,2 )
FileWrite ( $fTemp, $sData )
FileClose ( $fTemp )
TCPCloseSocket($iSocket)

Share this post


Link to post
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
Sign in to follow this  

×