Hack Forums
[Python] Raw socket returns raw hexadecimal data? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Raw socket returns raw hexadecimal data? (/showthread.php?tid=5538351)



Raw socket returns raw hexadecimal data? - Infamia - Jan 30, 2017

I'm not that inclined with raw sockets, so I'm trying to make a browser using them; sounds kind of stupid, but it's a kind of personal journey since [INSERT FEW YEARS AGO THIS AND THIS HAPPENED]. But on my quest I have encountered a discrepancy -- here is my code;

Code
from socket import *
headers = ["GET / HTTP/1.1\r\n",\
           "Host: www.evilzone.org\r\n",\
           "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)\r\n",\
           "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",\
           "Accept-Language: en-us,en;q=0.5\r\n",\
           "Accept-Encoding: gzip,deflate\r\n",\
            "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n",\
            "Keep-Alive: 300\r\n",\
            "Connection: keep-alive\r\n",\
            "Pragma: no-cache\r\n",\
            "Cache-Control: no-cache\r\n\r\n"]
a = socket(AF_INET, SOCK_STREAM)
a.connect(("www.evilzone.org", 80))
for x in headers: a.send(x)
buffer_ = a.recv(1024)
print buffer_

Not necessarily the prettiest, but here's my problem;

[Image: 5GqtxiG.png]

A t and a domino is returned as the supposed-to-be HTML, now I did my Googling; I'm not that contradictory of myself to constantly tell people to Google it and never do so myself -- the closest I got to figuring out what this was is a Stackoverflow/exchange post claiming it's a binary frame of some sort; here's the raw data from the 't/domino' combination;

Code
\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\xb3Q\xd4\xd5U\xf0H\xcd\xc9\xc9\xb7W\xd0\xd5\xb5\xe3\xb2\xc9\xccMW(.J\xb6U*\xc9HM\xcdK\xd1+\xc8KW\xb2\xe3\x02\x02\x1b\x90\xca\xf0\x8c\xc4\x12\x88B\xb8\x90\xa7By~^Jj\x91B9PN!\xb3X\x01H\x02\xf5*\x005+\xe4\xa7)$\xe6\xe4\x00\xb9\x99y\xe9\xc5\x10\xf3AZ\xbc=\x83\x83\xe1\x86 L\x8a\x89A(14A\xb0\xf5\xf5\xc1l\x00\xe0Q\xd3\x01\xab\x00\x00\x00

Maybe I'm just retarded, but I can't seem to figure out this issue :(

Thanks for any help in advance.


* - nooelec - Jan 30, 2017

Code
"Accept-Encoding: gzip,deflate\r\n",

The server is probably returning gzip encoded data in the response, hence the binary shit. Also, that is not a "raw socket", it is a TCP connection you are doing.

Edit: Definitely think it is gzip. The "\x1f\x8b" is indicative of that.


* - (╯°□°)╯︵ ┻━━┻ - Jan 30, 2017

(Jan 30, 2017 01:25 PM)nooelec Wrote:  
Code
"Accept-Encoding: gzip,deflate\r\n",

The server is probably returning gzip encoded data in the response, hence the binary shit. Also, that is not a "raw socket", it is a TCP connection you are doing.

Edit: Definitely think it is gzip. The "\x1f\x8b" is indicative of that.

Yeah I think this is right. Your response encoding is messed up.


* - Infamia - Jan 30, 2017

(Jan 30, 2017 01:25 PM)nooelec Wrote:  
Code
"Accept-Encoding: gzip,deflate\r\n",

The server is probably returning gzip encoded data in the response, hence the binary shit. Also, that is not a "raw socket", it is a TCP connection you are doing.

Edit: Definitely think it is gzip. The "\x1f\x8b" is indicative of that.

Oooh, alright; thanks. I'll look into it.

[Image: xlFOgbv.png]


YESSS I LOVEE YOU ALLL