MCPcopy
hub / github.com/trustedsec/social-engineer-toolkit / grab_ipaddress

Function grab_ipaddress

src/core/setcore.py:429–457  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

427# grab the interface ip address
428#
429def grab_ipaddress():
430 try:
431 rhost = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
432 rhost.connect(('google.com', 0))
433 rhost.settimeout(2)
434 revipaddr = rhost.getsockname()[0]
435 rhost = raw_input(setprompt("0", "IP address or URL (www.ex.com) for the payload listener (LHOST) [" + revipaddr + "]"))
436 if rhost == "": rhost = revipaddr
437
438 except Exception:
439 rhost = raw_input(setprompt("0", "Enter your interface/reverse listener IP Address or URL"))
440
441 if validate_ip(rhost) == False:
442 while 1:
443 choice = raw_input(setprompt(["2"], "This is not an IP address. Are you using a hostname? [y/n] "))
444 if choice == "" or choice.lower() == "y":
445 print_status("Roger that ghostrider. Using hostnames moving forward (hostnames are 1337, nice job)..")
446 break
447 else:
448 rhost = raw_input(setprompt(["2"], "IP address for the reverse connection [" + rhost + "]"))
449 if validate_ip(rhost) == True: break
450 else:
451 choice = raw_input(setprompt(["2"], "This is not an IP address. Are you using a hostname? [y/n] "))
452 if choice == "" or choice.lower() == "y":
453 print_status("Roger that ghostrider. Using hostnames moving forward (hostnames are 1337, nice job)..")
454 break
455
456 # rhost return when verified
457 return rhost
458
459#
460# cleanup old or stale files

Callers 6

binary2teensy.pyFile · 0.85
site_clonerFunction · 0.85
teensy_pde_generatorFunction · 0.85
set.pyFile · 0.85
create_payload.pyFile · 0.85
gen_hta_cool_stuffFunction · 0.85

Calls 3

setpromptFunction · 0.85
validate_ipFunction · 0.85
print_statusFunction · 0.85

Tested by

no test coverage detected