Author Topic: [Source] PyAgent User Agent Generator  (Read 3346 times)

0 Members and 2 Guests are viewing this topic.

Offline harvey

  • /dev/null
  • *
  • Posts: 8
  • Cookies: -3
    • View Profile
[Source] PyAgent User Agent Generator
« on: September 28, 2013, 08:07:04 am »
PyAgent
--------------------------------------------------
A Python random user agent generator.

INFORMATION
This handy little script can be used in your source codes to generate a random user agents.
The resulted user agents will vary between Chrome, Internet Explorer, and Firefox, appearing to be on a Linux, Mac, or Windows computer.
The platform and just about everything down the browsers version is all random, while still being a legitimate user agent.

USAGE
Running this script itself will not do anything, this is simply a function meant to be included in your source code.
The function can be called with "getUserAgent()", which will return the randomly generated agent to a string.

SOURCE CODE
Pastebin link

Code: (python) [Select]
# PyAgent User Agent Generator
# Version 1.0.0
# Coded by InvisibleMan in Python 2.7.5
# Download : N/A
# File     : pyagent.py

#IMPORTS
import datetime
import random

#GET USER-AGENT
def getUserAgent():
    platform = random.choice(['Macintosh', 'Windows', 'X11'])
    if platform == 'Macintosh':
        os  = random.choice(['68K', 'PPC'])
    elif platform == 'Windows':
        os  = random.choice(['Win3.11', 'WinNT3.51', 'WinNT4.0', 'Windows NT 5.0', 'Windows NT 5.1', 'Windows NT 5.2', 'Windows NT 6.0', 'Windows NT 6.1', 'Windows NT 6.2', 'Win95', 'Win98', 'Win 9x 4.90', 'WindowsCE'])
    elif platform == 'X11':
        os  = random.choice(['Linux i686', 'Linux x86_64'])
    browser = random.choice(['chrome', 'firefox', 'ie'])
    if browser == 'chrome':
        webkit = str(random.randint(500, 599))
        version = str(random.randint(0, 28)) + '.0' + str(random.randint(0, 1500)) + '.' + str(random.randint(0, 999))
        return 'Mozilla/5.0 (' + os + ') AppleWebKit/' + webkit + '.0 (KHTML, like Gecko) Chrome/' + version + ' Safari/' + webkit
    elif browser == 'firefox':
        currentYear = datetime.date.today().year
        year = str(random.randint(2000, currentYear))
        month = random.randint(1, 12)
        if month < 10:
            month = '0' + str(month)
        else:
            month = str(month)
        day = random.randint(1, 30)
        if day < 10:
            day = '0' + str(day)
        else:
            day = str(day)
        gecko = year + month + day
        version = str(random.randint(1, 21)) + '.0'
        return 'Mozilla/5.0 (' + os + '; rv:' + version + ') Gecko/' + gecko + ' Firefox/' + version
    elif browser == 'ie':
        version = str(random.randint(1, 10)) + '.0'
        engine = str(random.randint(1, 5)) + '.0'
        option = random.choice([True, False])
        if option == True:
            token = random.choice(['.NET CLR', 'SV1', 'Tablet PC', 'Win64; IA64', 'Win64; x64', 'WOW64']) + '; '
        else:
            token = ''
        return 'Mozilla/5.0 (compatible; MSIE ' + version + '; ' + os + '; ' + token + 'Trident/' + engine + ')'
« Last Edit: September 28, 2013, 08:33:20 pm by Kulverstukas »

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: [Source] PyAgent User Agent Generator
« Reply #1 on: September 28, 2013, 12:11:08 pm »
adf.ly...
Gtfo
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline rasenove

  • Baron
  • ****
  • Posts: 950
  • Cookies: 53
  • ಠ_ಠ
    • View Profile
Re: [Source] PyAgent User Agent Generator
« Reply #2 on: September 28, 2013, 12:24:24 pm »
OP, use the EZ upload service,  its better in all means.

www.upload.evilzone.org/

And don't mind proxx, he's just excited...
My secrets have secrets...

Offline harvey

  • /dev/null
  • *
  • Posts: 8
  • Cookies: -3
    • View Profile
Re: [Source] PyAgent User Agent Generator
« Reply #3 on: September 28, 2013, 01:02:16 pm »
Nothing is being uploaded, it's a link to a Pastebin, and if you noticed, I supplied a non-adfly link.

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: [Source] PyAgent User Agent Generator
« Reply #4 on: September 28, 2013, 02:58:10 pm »
I took away unneeded whitespace, and removed the ad link. We don't do the whole ad things here, don't do it in the future. I left the colors cause I thought it kinda fits the python color scheme.
>>>import this
-----------------------------

Offline rasenove

  • Baron
  • ****
  • Posts: 950
  • Cookies: 53
  • ಠ_ಠ
    • View Profile
Re: [Source] PyAgent User Agent Generator
« Reply #5 on: September 28, 2013, 03:07:19 pm »
Nothing is being uploaded, it's a link to a Pastebin, and if you noticed, I supplied a non-adfly link.

Then paste the code here, using BBcode.
My secrets have secrets...

Offline harvey

  • /dev/null
  • *
  • Posts: 8
  • Cookies: -3
    • View Profile
Re: [Source] PyAgent User Agent Generator
« Reply #6 on: September 28, 2013, 03:19:23 pm »
I took away unneeded whitespace, and removed the ad link. We don't do the whole ad things here, don't do it in the future. I left the colors cause I thought it kinda fits the python color scheme.


Apologies, wont happen again.