Ejemplo n.º 1
0
 def __init__(self, user_agent=False, proxy=False):
     self.proxy = {}
     self.session = requests.Session()
     if user_agent:
         self.session.headers.update(
             {'User-agent', '{}'.format(UserAgent().get())})
     if proxy:
         ip = Proxy().get()
         self.proxy['http'] = 'http://{}'.format(ip)
         self.proxy['https'] = 'https://{}'.format(ip)
Ejemplo n.º 2
0
 def _func(*args, **kwargs):
     log.warning('HERE MNA --- MM1')
     if request.method != method:
         log.warning('view_method_error|url=%s,method=%s',
                     get_request_url().encode('utf-8'), request.method)
         return error_handler()
     if isinstance(form, FormValidator):
         if method == 'GET':
             formdata = request.args
         else:
             formdata = request.form
         try:
             data = form.normalize(formdata)
         except Exception as ex:
             log.warning(
                 'view_params_error|format=form,url=%s,error=%s,body=%s',
                 get_request_url().encode('utf-8'), ex,
                 request.get_data())
             return error_handler()
     else:
         if data_format == 'JSON':
             log.warning('HERE MNA --- MM')
             request_body = request.get_data()
             try:
                 data = jsonutils.from_json(request_body)
             except Exception as ex:
                 log.warning(
                     'view_params_error|format=json,url=%s,error=%s,body=%s',
                     get_request_url().encode('utf-8'), ex,
                     request_body)
                 #return error_handler()
                 data = {}
             if form is not None:
                 params_errors = [
                     e.message for e in form.iter_errors(data)
                 ]
                 if params_errors:
                     log.warning(
                         'view_params_error|format=json,url=%s,error=json_validotor:%s,body=%s',
                         get_request_url().encode('utf-8'),
                         ';'.join(params_errors), request_body)
                     return error_handler()
         else:
             data = request.values
     data['request_ip'] = get_request_ip(request)
     if parse_ua:
         data['request_ua'] = UserAgent(
             (request.headers.get('User-Agent', '')))
     return func(data, *args, **kwargs)
Ejemplo n.º 3
0
 def __init__(self,
              db_username,
              db_password,
              db_name,
              db_proxy_table,
              db_host="127.0.0.1"):
     self.userAgent = UserAgent()
     self.proxyGetter = Proxy(db_username, db_password, db_host, db_name,
                              db_proxy_table)
     self.proxy_list = []
     self.current_proxy = None
     self.proxy_time_start_used = 0
     self.logger = logging.getLogger()
     self.logger.addHandler(handler)
     self.logger.setLevel(0)
Ejemplo n.º 4
0
def map(key, logline):
    try:
        parsed = ApacheLogParser().parse(logline)
    except:
        return

    # timestamp of format yyyymmdd.
    timestamp = ymd(parsed['epoch'])

    # dimension attributes are strings.
    dimensions = {}
    dimensions['host'] = parsed['host']
    dimensions['method'] = parsed['method']
    dimensions['path'] = parsed['path']
    dimensions['status'] = parsed['status']
    dimensions['referrer'] = parsed['referrer']
    dimensions['agent'] = UserAgent(parsed['agent']).classify()

    # measurements are integers.
    measurements = {}
    measurements['bytes'] = int(parsed['size'])
    measurements['requests'] = 1

    yield timestamp, dimensions, measurements
Ejemplo n.º 5
0
from splinter import Browser
from selenium import webdriver
from getproxies import *
from useragent import UserAgent

proxies = get_proxies()
url = "https://www.expressvpn.com/what-is-my-ip"

for proxy in proxies:
    print("Proxy: " + proxy)
    ua = UserAgent()
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--proxy-server=%s' % proxy)
    chrome_options.add_argument('user-agent=' + ua.get_user_agent("chrome"))
    try:
        browser = Browser('chrome', options=chrome_options)
        browser.visit(url)
        ip_address = browser.find_by_css('p[class="ip-address"]').text
        if ip_address == proxy['ip']:
            print("IP address match with Proxy: " + ip_address)
            browser.quit()
            break
    except Exception as e:
        browser.quit()
        print("Trying another proxy....")
        continue
Ejemplo n.º 6
0
 def __init__(self):
     self.ua = UserAgent(handlers=[NoRedirects, NoErrors])
Ejemplo n.º 7
0
 def test_classify(self):
     user_agent_string = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'
     ua = UserAgent(user_agent_string)
     self.assertEqual(ua.classify(), "firefox")
     self.assertTrue(ua.is_browser())
     self.assertFalse(ua.is_robot())
Ejemplo n.º 8
0
def get_token(ip):
    ua = UserAgent('POST', '{}/getSecure'.format(ip))
    r = ua.SendRequest()
    return read_response(r)
Ejemplo n.º 9
0
def get_token(ip):
    ua = UserAgent('POST', '{}/getSecure'.format(ip))
    r = ua.SendRequest()
    return read_response(r)


if __name__ == '__main__':
    ip = '54.209.150.110'
    headers = DEFAULT_HEADERS
    parameters = {
        'username': '******',
        'token': get_token(ip),
    }

    # Activity #1
    ua = UserAgent('POST', '{}/'.format(ip))
    r = ua.SendRequest()
    f = read_response(r)
    print('Activity 1 Flag: ' + f)

    # Activity #2
    ua = UserAgent('POST',
                   '{}/getFlag2'.format(ip),
                   parameters=parameters,
                   ie_headers=True)
    r = ua.SendRequest()
    f = read_response(r)
    print('Activity 2 Flag: ' + f)

    # Activity #3
    ua = UserAgent('POST',