hello i am new to Ruby. i want to make a small program that when you scan the computer with NMAP it will look like a real program. some kind of small honeypot. i am trying to do it with pop3,ssh,smtp,http,ftp,telnet and RDP. every protocol is a different port of course so i am changing the port and the header. i've succeeded only with smtp and ftp. please help with the other. the code is : require 'socket' server = TCPServer.open(80) hostname = Socket.gethostbyname(Socket.gethostname).first header1 = "HTTP/1.1 200 OK" header2 = "Fri 11 Jan 2013 13:13:13 GMT" header7 = "Location: www.fuckyou.com/" header3 = "Server: Microsoft-IIS/6.0" header4 = "Vary: Accept-Encoding" header5 = "Connection: close" header6 = "Content-Type: text/html; charset=iso-8859-1" loop do Thread.start(server.accept) do |client| client.write header1 client.write header2 client.write header7 client.write header3 client.write header4 client.write header5 client.write header6 client.close end end and it still now working. another thing - can i post all of the headers 1-6 in one header ? thanks you very much
on 2013-01-12 15:19
on 2013-01-12 16:23
Try separating your headers with newlines, according to HTTP standard. Also, this might be of interest: http://apidock.com/ruby/Socket/tcp_server_loop/class
on 2013-01-12 16:56
hello thank you very much. i had a problem with all the headers so i found a nice option i wrote all the lines in HEX and used .pack(H*)
on 2013-01-12 17:34
On Sat, Jan 12, 2013 at 8:19 AM, Ophir O. <lists@ruby-forum.com> wrote:
> another thing - can i post all of the headers 1-6 in one header ?
headers = []
headers << "HTTP/1.1 200 OK"
headers << "Fri 11 Jan 2013 13:13:13 GMT"
headers << "Server: Microsoft-IIS/6.0"
headers << "Vary: Accept-Encoding"
headers << "Connection: close"
headers << "Content-Type: text/html; charset=iso-8859-1"
headers << "Location: www.fuckyou.com/"
headers << ""
...
client.write headers.join("\r\n")
on 2013-01-12 17:52
means return + newline. Windows's way of dictating the end of a line in a file. Unix uses just '\r' Ophir O. wrote: > thank you very much ! > can you please explain what is "\r\n" ? > -- D. Deryl Downey "The bug which you would fright me with I seek" - William Shakespeare - The Winter's Tale, Act III, Scene II - A court of Justice.
on 2013-01-12 18:01
More specifically, "\r\n" denotes a carriage return line feed pair, sometimes referred to as CRLF. You should find quite a bit in a Google search for those terms. Also, a correction. Unix uses just the line feed character (LF or "\n"), not the carriage return character (CR or "\r"). Other systems may use other combinations. :-) "D. Deryl Downey" <me@daviddwdowney.com> wrote: > >-- >D. Deryl Downey > >"The bug which you would fright me with I seek" - William Shakespeare - > >The Winter's Tale, Act III, Scene II - A court of Justice. -Jeremy
on 2013-01-12 18:06
Thank you for correcting my mistake. That is correct. My apologies. Jeremy Bopp wrote: > means return + newline. Windows's way of dictating the end of a line in > > > -Jeremy > > -- > Sent from my mobile device. Please excuse my brevity. -- D. Deryl Downey "The bug which you would fright me with I seek" - William Shakespeare - The Winter's Tale, Act III, Scene II - A court of Justice.
on 2013-01-13 03:17
On Sat, Jan 12, 2013 at 11:00 AM, Jeremy Bopp <jeremy@bopp.net> wrote: > More specifically, "\r\n" denotes a carriage return line feed pair, > sometimes referred to as CRLF. You should find quite a bit in a Google > search for those terms. > > Also, a correction. Unix uses just the line feed character (LF or "\n"), not > the carriage return character (CR or "\r"). Other systems may use other > combinations. :-) Of particular importance to OP, HTTP protocol dictates that the header lines be separated with CRLF ("\r\n"). Other protocols do as well. That said, many servers are forgiving and will accept CR, LF, and CRLF. Postel set the tone in TCP with "send only what is correct, be forgiving in what you accept".
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.