Commit 8e8b1a1f authored by Daniel W Bond's avatar Daniel W Bond

added the files

parents
#!/usr/bin/perl
# Andrew Pennebaker
#
# Based on Colin Edwards' UAC Bypass
# http://www.recursivepenguin.com/index.php?projectID=3
#
# KOPIMI
use Error qw(:try);
use Crypt::SSLeay;
use WWW::Mechanize;
use HTML::TokeParser;
use strict;
# Get config variables from the command line.
#my ($url, $useragent, $success, $timeout, $username, $password)=@ARGV;
# Hardcoded config variables.
my $url="https://uac.gmu.edu/dana-na/auth/url_0/welcome.cgi?p=failed";
my $useragent="Windows Mozilla";
my $success="You have successfully logged in";
my $timeout=40;
my $username="USERNAME";
my $password="PASSWORD";
# From http://perl.coding-school.com/perl-timeout/
sub gripe {
throw Error::Simple("Timeout");
}
$SIG{ALRM}=\&gripe;
sub login {
my ($url, $ua, $s, $u, $p)=@_;
try {
my $agent=WWW::Mechanize->new( ssl_opts => {verify_hostname => 0 } );
$agent->agent_alias($ua);
alarm $timeout;
$agent->get($url);
alarm 0;
$agent->submit_form(form_number=>1, fields=>{username=>$u, password=>$p});
$agent->submit_form(form_number=>1);
return $agent->success && $agent->content =~ /$s/;
}
catch Error with {
print "Caught an error.\n";
return 0;
};
}
if (login($url, $useragent, $success, $username, $password)) {
print "success!\n";
exit 0;
}
else {
print "failure!\n";
exit -1;
}
#!/usr/bin/env python2.7
# Andrew Pennebaker
#
# Based on Colin Edwards' UAC Bypass
# http://www.recursivepenguin.com/index.php?projectID=3
from mechanize import Browser
import sys, re, time, ConfigParser, os, urllib2, signal
from getopt import getopt
def usage():
print "Usage: %s" % (sys.argv[0])
print "\n-c|--config <config file>"
print "-n|--no-config <options>"
print "\n-h|--help (usage)"
sys.exit()
def sig_handler(signum, frame):
raise IOError, "Timed out"
signal.signal(signal.SIGALRM, sig_handler)
def load(file):
try:
config=ConfigParser.ConfigParser()
config.readfp(open(file))
d={}
for key, value in config.items("Defaults"):
d[key]=value
return d
except Exception, e:
print "Could not open "+file
def login(settings):
br=Browser()
br.set_handle_robots(False)
br.addheaders=[("User-agent", settings["useragent"])];
try:
signal.alarm(settings["timeout"])
br.open(settings["url_wireless"])
signal.alarm(0)
br.select_form(name="frmLogin")
br["username"]=settings["username"]
br["password"]=settings["password"]
response=br.submit()
br.select_form(name="frmGrab")
response=br.submit()
return response.read().find(settings["success_wireless"])!=-1
except:
br=Browser()
br.set_handle_robots(False)
br.addheaders=[("User-agent", settings["useragent"])];
try:
signal.alarm(settings["timeout"])
br.open(settings["url"])
signal.alarm(0)
br.select_form(name="frmLogin")
br["username"]=settings["username"]
br["password"]=settings["password"]
response=br.submit()
br.select_form(name="frmGrab")
response=br.submit()
return response.read().find(settings["success"])!=-1
except:
return False
def main():
config=os.getcwd()+"/gilgamesh.ini"
no_config=False
systemArgs=sys.argv[1:] # ignore program name
optlist=[]
args=[]
try:
optlist, args=getopt(systemArgs, "c:nh", ["config", "no-config", "help"])
except Exception, e:
usage()
for option, value in optlist:
if option=="-h" or option=="--help":
usage()
elif option=="-c" or option=="--config":
config=value
elif option=="-n" or option=="--no-config":
no_config=True
if no_config:
settings={
"url": args[0],
"url_wireless": args[1],
"useragent": args[2],
"success": args[3],
"success_wireless": args[4],
"timeout": int(args[5]),
"username": args[6],
"password": args[7]
}
if login(settings):
sys.exit(0)
else:
sys.exit(1)
else:
settings=load(config)
settings["timeout"]=int(settings["timeout"])
settings["wait"]=int(settings["wait"])
trial_counter = 0
while True:
trial_counter = trial_counter + 1
t=time.strftime("%a %d %b %Y %H:%M", time.localtime())
if login(settings):
print "Login "+t
sys.exit(0)
else:
print "Failure "+t
sys.exit(1)
time.sleep(int(settings["wait"]))
if __name__=="__main__":
try:
main()
except KeyboardInterrupt, e:
pass
[Defaults]
url=https://uac.gmu.edu/dana-na/auth/url_0/welcome.cgi?p=failed
url_wireless=https://uacwireless.gmu.edu/dana-na/auth/url_0/welcome.cgi?p=failed
useragent=Windows Mozilla
success=You have successfully logged in
success_wireless=You have gained full access to the network
timeout:4
wait:2400
username=rbragg
password=
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment