├── BappDescription.html ├── BappManifest.bmf ├── LICENSE ├── LICENSE - sqlmap ├── README.md ├── SQLiPy.py └── sqlmap.zip /BappDescription.html: -------------------------------------------------------------------------------- 1 |
This extension integrates Burp Suite with SQLMap.
2 | 3 |Requirements:
4 |SQLMap comes with a RESTful based server that will execute SQLMap scans. You can manually start the server 10 | with:
11 |python sqlmapapi.py -s -H <ip> -p <port> 12 |13 |
Alternatively, you can use the SQLMap API tab to select the IP/Port on which to run, as well as the path to python and sqlmapapi.py on your system. 14 | 15 |
16 |Once the SQLMap API is running, you just need to right-click in the 'Request' 17 | sub tab of either the Target or Proxy main tabs and choose 'SQLiPy Scan' from 18 | the context menu. 19 | 20 | This will populate the SQLMap Scanner tab with information about that request. Clicking the 'Start Scan' button will execute a scan. 21 | 22 | If the page is vulnerable to SQL injection, then these will be added to the Scanner Results tab. 23 |
24 | -------------------------------------------------------------------------------- /BappManifest.bmf: -------------------------------------------------------------------------------- 1 | Uuid: f154175126a04bfe8edc6056f340f52e 2 | ExtensionType: 2 3 | Name: SQLiPy Sqlmap Integration 4 | RepoName: sqli-py 5 | ScreenVersion: 0.8.6 6 | SerialVersion: 19 7 | MinPlatformVersion: 0 8 | ProOnly: False 9 | Author: Josh Berry @ CodeWatch 10 | ShortDescription: Initiates SQLMap scans directly from within Burp. 11 | EntryPoint: SQLiPy.py 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to21 | python sqlmapapi.py -s -H <ip> -p <port> 22 |23 | 24 | Or, you can use the SQLMap API tab to select the IP/Port on which to run, as well as the path to python and sqlmapapi.py on your system. 25 | 26 | Once the SQLMap API is running, it is just a matter of right mouse clicking in the 'Request' sub tab of either the Target or Proxy main tabs and choosing 'SQLiPy Scan'. 27 | 28 | This will populate the SQLMap Scanner tab of the plugin with information about that request. Clicking the 'Start Scan' button will execute a scan. 29 | 30 | If the page is vulnerable to SQL injection, then a thread from the plugin will poll the results and add them to the Scanner Results tab. 31 | 32 | For more information, see the post here: https://www.codewatch.org/blog/?p=402 33 | -------------------------------------------------------------------------------- /SQLiPy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Name: SQLiPy 3 | Version: 0.8.6 4 | Date: 9/3/2014 5 | Author: Josh Berry - josh.berry@codewatch.org 6 | Github: https://github.com/codewatchorg/sqlipy 7 | 8 | Description: This plugin leverages the SQLMap API to initiate SQLMap scans against the target. 9 | 10 | This plugin requires the beta version of Jython as it uses the JSON module. 11 | 12 | I used this blog post to quickly understand and leverage the SQLMap API (thrilled that someone figured this out for me): 13 | http://volatile-minds.blogspot.com/2013/04/unofficial-sqlmap-restful-api.html 14 | 15 | The following Burp plugins were reviewed to help develop this: 16 | - Payload Parser: https://github.com/infodel 17 | - Burp SAMl: https://github.com/Meatballs1/burp_saml 18 | - ActiveScan++: 19 | - WCF Binary SOAP Handler: http://blog.securityps.com/2013/02/burp-suite-plugin-view-and-modify-wcf.html 20 | - WSDL Wizard: https://github.com/SmeegeSec/WSDLWizard/blob/master/WSDLWizard.py 21 | - co2: https://code.google.com/p/burp-co2/ 22 | 23 | """ 24 | 25 | from burp import IBurpExtender 26 | from burp import IBurpExtenderCallbacks 27 | from burp import IContextMenuFactory 28 | from burp import IHttpRequestResponse 29 | from burp import IMessageEditorController 30 | from burp import IMessageEditorTabFactory 31 | from burp import ITab 32 | from burp import IMessageEditorTab 33 | from burp import IScannerCheck 34 | from burp import IScanIssue 35 | from burp import IExtensionStateListener 36 | from javax import swing 37 | from javax.swing.filechooser import FileNameExtensionFilter 38 | from java.awt import GridBagLayout 39 | from java.awt import Font 40 | from java.awt import Color 41 | from java import awt 42 | from java.lang import Runtime 43 | from java.lang import Process 44 | from java.lang import System 45 | from java.lang import Runnable 46 | from java.lang import Thread 47 | from java.io import File 48 | from java.io import Reader 49 | from java.io import BufferedReader 50 | from java.io import InputStreamReader 51 | import subprocess 52 | import re 53 | import urllib2 54 | import sys 55 | import json 56 | import threading 57 | import time 58 | import zipfile 59 | import os 60 | import traceback 61 | 62 | class StreamGobbler(Runnable): 63 | 64 | def __init__(self, inStream, outStream): 65 | self.inStream = inStream 66 | self.outStream = outStream 67 | return 68 | 69 | def run(self): 70 | try: 71 | while (self.inStream.read() != -1): 72 | isr = InputStreamReader(self.inStream) 73 | br = BufferedReader(isr) 74 | print str(br.readLine()) 75 | 76 | except BaseException as ex: 77 | print 'Could not read API input/output/error buffer\n' 78 | 79 | class SqlMapScanIssue(IScanIssue): 80 | 81 | def __init__(self, httpService, url, httpMessages, name, detail, confidence, severity): 82 | self.HttpService = httpService 83 | self.vulnurl = url 84 | self.HttpMessages = httpMessages 85 | self.vulnname = name 86 | self.vulndetail = detail 87 | self.vulnsev = severity 88 | self.vulnconf = confidence 89 | return 90 | 91 | def getUrl(self): 92 | return self.vulnurl 93 | 94 | def getIssueName(self): 95 | return self.vulnname 96 | 97 | def getIssueType(self): 98 | return 0 99 | 100 | def getSeverity(self): 101 | return self.vulnsev 102 | 103 | def getConfidence(self): 104 | return self.vulnconf 105 | 106 | def getIssueBackground(self): 107 | return None 108 | 109 | def getRemediationBackground(self): 110 | return None 111 | 112 | def getIssueDetail(self): 113 | return self.vulndetail 114 | 115 | def getRemediationDetail(self): 116 | return None 117 | 118 | def getHttpMessages(self): 119 | return self.HttpMessages 120 | 121 | def getHttpService(self): 122 | return self.HttpService 123 | 124 | class ThreadExtender(IBurpExtender, IContextMenuFactory, ITab, IScannerCheck): 125 | def __init__(self, burpobject, sqlmapip, sqlmapport, sqlmaptask, url, httpmessage, cbacks): 126 | self.burpobject = burpobject 127 | self.sqlmapip = sqlmapip 128 | self.sqlmapport = sqlmapport 129 | self.sqlmaptask = sqlmaptask 130 | self.url = url 131 | self.httpmessage = httpmessage 132 | self.cbacks = cbacks 133 | 134 | def checkResults(self): 135 | t = threading.currentThread() 136 | time.sleep(5) 137 | print 'Checking results on task: '+self.sqlmaptask+'\n' 138 | 139 | while getattr(t, "keep_running", True): 140 | 141 | try: 142 | req = urllib2.Request('http://' + str(self.sqlmapip) + ':' + str(self.sqlmapport) + '/scan/' + str(self.sqlmaptask) + '/status') 143 | req.add_header('Content-Type', 'application/json') 144 | resp = json.load(urllib2.urlopen(req, timeout=10)) 145 | 146 | if resp['status'] == "running": 147 | print 'Scan for task '+self.sqlmaptask+' is still running.\n' 148 | time.sleep(30) 149 | elif resp['status'] == "terminated": 150 | if resp['returncode'] == 0: 151 | print 'Scan for task '+self.sqlmaptask+' completed. Gathering results.\n' 152 | vulnurl = '' 153 | vulnparam = '' 154 | dbtype = '' 155 | payloads = '' 156 | banner = '' 157 | cu = '' 158 | cdb = '' 159 | hostname = '' 160 | isdba = '' 161 | lusers = '' 162 | lprivs = '' 163 | lroles = '' 164 | ldbs = '' 165 | lpswds = '' 166 | 167 | try: 168 | req = urllib2.Request('http://' + str(self.sqlmapip) + ':' + str(self.sqlmapport) + '/scan/' + str(self.sqlmaptask) + '/data') 169 | req.add_header('Content-Type', 'application/json') 170 | resp = json.load(urllib2.urlopen(req, timeout=10)) 171 | vulnerable = False 172 | 173 | for findings in resp['data']: 174 | vulnerable = True 175 | 176 | # Get vulnerable URL and param 177 | if findings['type'] == 0: 178 | vulnurl = findings['value']['url'] 179 | vulnparam = findings['value']['query'] 180 | vulndetails = '
The application has been found to be vulnerable to SQL injection by SQLMap.
Vulnerable URL and Parameter:
'+vulndetails+'
') 356 | findings.write('The following payloads successfully identified SQL injection vulnerabilities:
'+payloads+'
Enumerated Data:
'+dbtype+': '+banner+'
'+cu+'
'+cdb+'
'+hostname+'
'+isdba+'
'+lusers+'
'+lpswds+'
'+lprivs+'
'+lroles+'
'+ldbs+'
') 357 | findings.write('') 358 | findings.close() 359 | print 'Wrote scan file ' + self.sqlmaptask + '.html\n' 360 | else: 361 | scanIssue = SqlMapScanIssue(self.httpmessage.getHttpService(), self.url, [self.httpmessage], 'SQLMap Scan Finding', 362 | 'The application has been found to be vulnerable to SQL injection by SQLMap.'+vulndetails+'
'+payloads+'
Enumerated Data:
'+dbtype+': '+banner+'
'+cu+'
'+cdb+'
'+hostname+'
'+isdba+'
'+lusers+'
'+lpswds+'
'+lprivs+'
'+lroles+'
'+ldbs+'
', 'Certain', 'High') 363 | self.cbacks.addScanIssue(scanIssue) 364 | 365 | print 'SQLi vulnerabilities were found for task '+self.sqlmaptask+' and have been reported.\n' 366 | else: 367 | print 'Scan completed for task '+self.sqlmaptask+' but SQLi vulnerabilities were not found.\n' 368 | 369 | break 370 | 371 | except: 372 | print 'No results for SQLMap task: '+self.sqlmaptask+'\n' 373 | break 374 | 375 | else: 376 | print 'SQLMap scan failed for task: '+self.sqlmaptask+'\n' 377 | break 378 | 379 | else: 380 | print 'SQLMap scan failed for task: '+self.sqlmaptask+'\n' 381 | break 382 | 383 | except: 384 | print 'Thread failed to get results for SQLMap task: ' + self.sqlmaptask+'\n' 385 | break 386 | 387 | class BurpExtender(IBurpExtender, IContextMenuFactory, ITab, IExtensionStateListener): 388 | pythonfile = '' 389 | apifile = '' 390 | apiprocess = Process 391 | apistatus = 0 392 | threads = [] 393 | scanMessage = '' 394 | scantasks = [] 395 | scancmds = {} 396 | 397 | # Implement IBurpExtender 398 | def registerExtenderCallbacks(self, callbacks): 399 | # Print information about the plugin, set extension name, setup basic stuff 400 | self.printHeader() 401 | callbacks.setExtensionName("SQLiPy Sqlmap Integration") 402 | callbacks.registerExtensionStateListener(self) 403 | self._callbacks = callbacks 404 | self._helpers = callbacks.getHelpers() 405 | callbacks.registerContextMenuFactory(self) 406 | 407 | # Create SQLMap API configuration JPanel 408 | self._jPanel = swing.JPanel() 409 | self._jPanel.setLayout(awt.GridBagLayout()) 410 | self._jPanelConstraints = awt.GridBagConstraints() 411 | 412 | # Create first blank space 413 | self._jLabelAPISpace1 = swing.JLabel(" ") 414 | self._jLabelAPISpace1.setFont(Font("Courier New", Font.BOLD, 30)) 415 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 416 | self._jPanelConstraints.gridx = 0 417 | self._jPanelConstraints.gridy = 2 418 | self._jPanelConstraints.gridwidth = 2 419 | self._jPanel.add(self._jLabelAPISpace1, self._jPanelConstraints) 420 | 421 | # Create second blank space 422 | self._jLabelAPISpace2 = swing.JLabel(" ") 423 | self._jLabelAPISpace2.setFont(Font("Courier New", Font.BOLD, 30)) 424 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 425 | self._jPanelConstraints.gridx = 0 426 | self._jPanelConstraints.gridy = 3 427 | self._jPanelConstraints.gridwidth = 2 428 | self._jPanel.add(self._jLabelAPISpace2, self._jPanelConstraints) 429 | 430 | # Create panel to show API status 431 | self._jLabelAPIStatus = swing.JLabel("SQLMap API is NOT running!") 432 | self._jLabelAPIStatus.setFont(Font("Courier New", Font.BOLD, 24)) 433 | self._jLabelAPIStatus.setForeground(Color.RED) 434 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 435 | self._jPanelConstraints.gridx = 0 436 | self._jPanelConstraints.gridy = 4 437 | self._jPanelConstraints.gridwidth = 2 438 | self._jPanel.add(self._jLabelAPIStatus, self._jPanelConstraints) 439 | 440 | # Create third blank space 441 | self._jLabelAPISpace3 = swing.JLabel(" ") 442 | self._jLabelAPISpace3.setFont(Font("Courier New", Font.BOLD, 30)) 443 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 444 | self._jPanelConstraints.gridx = 0 445 | self._jPanelConstraints.gridy = 5 446 | self._jPanelConstraints.gridwidth = 2 447 | self._jPanel.add(self._jLabelAPISpace3, self._jPanelConstraints) 448 | 449 | # Create panel for IP info 450 | self._jLabelIPListen = swing.JLabel("Listen on IP:") 451 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 452 | self._jPanelConstraints.gridx = 0 453 | self._jPanelConstraints.gridy = 6 454 | self._jPanelConstraints.gridwidth = 1 455 | self._jPanel.add(self._jLabelIPListen, self._jPanelConstraints) 456 | 457 | self._jTextFieldIPListen = swing.JTextField("127.0.0.1",15) 458 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 459 | self._jPanelConstraints.gridx = 1 460 | self._jPanelConstraints.gridy = 6 461 | self._jPanelConstraints.gridwidth = 1 462 | self._jPanel.add(self._jTextFieldIPListen, self._jPanelConstraints) 463 | 464 | # Create panel for Port info 465 | self._jLabelPortListen = swing.JLabel("Listen on Port:") 466 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 467 | self._jPanelConstraints.gridx = 0 468 | self._jPanelConstraints.gridy = 7 469 | self._jPanelConstraints.gridwidth = 1 470 | self._jPanel.add(self._jLabelPortListen, self._jPanelConstraints) 471 | 472 | self._jTextFieldPortListen = swing.JTextField("9090",3) 473 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 474 | self._jPanelConstraints.gridx = 1 475 | self._jPanelConstraints.gridy = 7 476 | self._jPanelConstraints.gridwidth = 1 477 | self._jPanel.add(self._jTextFieldPortListen, self._jPanelConstraints) 478 | 479 | # Create panel to contain Python button 480 | self._jLabelPython = swing.JLabel("Select Python:") 481 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 482 | self._jPanelConstraints.gridx = 0 483 | self._jPanelConstraints.gridy = 8 484 | self._jPanelConstraints.gridwidth = 1 485 | self._jPanel.add(self._jLabelPython, self._jPanelConstraints) 486 | 487 | self._jButtonSetPython = swing.JButton('Python', actionPerformed=self.setPython) 488 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 489 | self._jPanelConstraints.gridx = 1 490 | self._jPanelConstraints.gridy = 8 491 | self._jPanelConstraints.gridwidth = 1 492 | self._jPanel.add(self._jButtonSetPython, self._jPanelConstraints) 493 | 494 | # Create panel to contain API button 495 | self._jLabelAPI = swing.JLabel("Select API:") 496 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 497 | self._jPanelConstraints.gridx = 0 498 | self._jPanelConstraints.gridy = 9 499 | self._jPanelConstraints.gridwidth = 1 500 | self._jPanel.add(self._jLabelAPI, self._jPanelConstraints) 501 | 502 | self._jButtonSetAPI = swing.JButton('SQLMap API', actionPerformed=self.setAPI) 503 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 504 | self._jPanelConstraints.gridx = 1 505 | self._jPanelConstraints.gridy = 9 506 | self._jPanelConstraints.gridwidth = 1 507 | self._jPanel.add(self._jButtonSetAPI, self._jPanelConstraints) 508 | 509 | # Create panel to execute API 510 | self._jButtonStartAPI = swing.JButton('Start API', actionPerformed=self.startAPI) 511 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 512 | self._jPanelConstraints.gridx = 0 513 | self._jPanelConstraints.gridy = 10 514 | self._jPanelConstraints.gridwidth = 2 515 | self._jPanel.add(self._jButtonStartAPI, self._jPanelConstraints) 516 | 517 | # Create panel to stop API 518 | self._jButtonStopAPI = swing.JButton('Stop API', actionPerformed=self.stopAPI) 519 | self._jPanelConstraints.fill = awt.GridBagConstraints.HORIZONTAL 520 | self._jPanelConstraints.gridx = 0 521 | self._jPanelConstraints.gridy = 11 522 | self._jPanelConstraints.gridwidth = 2 523 | self._jPanel.add(self._jButtonStopAPI, self._jPanelConstraints) 524 | 525 | # Create SQLMap scanner panel 526 | # Combobox Values 527 | httpMethodValues = ['Default', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH'] 528 | levelValues = [1,2,3,4,5] 529 | riskValues = [0,1,2,3] 530 | threadValues = [1,2,3,4,5,6,7,8,9,10] 531 | delayValues = [0,1,2,3,4,5] 532 | timeoutValues = [1,5,10,15,20,25,30,35,40,45,50,55,60] 533 | retryValues = [1,2,3,4,5,6,7,8,9,10] 534 | dbmsValues = ['Any', 'MySQL', 'Oracle', 'PostgreSQL', 'Microsoft SQL Server', 'Microsoft Access', 'SQLite', 'Firebird', 'Sybase', 'SAP MaxDB', 'DB2', 'Informix', 'MariaDB', 'Percona', 'MemSQL', 'TiDB', 'CockroachDB', 'HSQLDB', 'H2', 'MonetDB', 'Apache Derby', 'Amazon Redshift', 'Vertica', 'Mckoi', 'Presto', 'Altibase', 'MimerSQL', 'CrateDB', 'Greenplum', 'Drizzle', 'Apache Ignite', 'Cubrid', 'InterSystems Cache', 'IRIS', 'eXtremeDB', 'FrontBase'] 535 | authTypes = ['None', 'Basic', 'Digest', 'NTLM'] 536 | osValues = ['Any', 'Linux', 'Windows'] 537 | timeSecValues = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] 538 | torTypes = ['HTTP', 'SOCKS4', 'SOCKS5'] 539 | 540 | # GUI components 541 | self._jLabelScanText = swing.JLabel() 542 | self._jLabelScanIPListen = swing.JLabel() 543 | self._jLabelScanPortListen = swing.JLabel() 544 | self._jTextFieldScanIPListen = swing.JTextField() 545 | self._jTextFieldScanPortListen = swing.JTextField() 546 | self._jSeparator1 = swing.JSeparator() 547 | self._jLabelHttpMethod = swing.JLabel() 548 | self._jLabelIgnoreCode = swing.JLabel() 549 | self._jComboHttpMethod = swing.JComboBox(httpMethodValues) 550 | self._jTextFieldIgnoreCode = swing.JTextField() 551 | self._jLabelURL = swing.JLabel() 552 | self._jTextFieldURL = swing.JTextField() 553 | self._jLabelData = swing.JLabel() 554 | self._jTextData = swing.JTextArea() 555 | self._jScrollPaneData = swing.JScrollPane(self._jTextData) 556 | self._jLabelCookie = swing.JLabel() 557 | self._jTextFieldCookie = swing.JTextField() 558 | self._jLabelReferer = swing.JLabel() 559 | self._jTextFieldReferer = swing.JTextField() 560 | self._jLabelUA = swing.JLabel() 561 | self._jTextFieldUA = swing.JTextField() 562 | self._jLabelCustHeader = swing.JLabel() 563 | self._jTextFieldCustHeader = swing.JTextField() 564 | self._jCustHeadCheckParam = swing.JCheckBox() 565 | self._jSeparator2 = swing.JSeparator() 566 | self._jLabelParam = swing.JLabel() 567 | self._jTextFieldParam = swing.JTextField() 568 | self._jCheckTO = swing.JCheckBox() 569 | self._jSeparator3 = swing.JSeparator() 570 | self._jComboLevel = swing.JComboBox(levelValues) 571 | self._jLabelLevel = swing.JLabel() 572 | self._jLabelRisk = swing.JLabel() 573 | self._jComboRisk = swing.JComboBox(riskValues) 574 | self._jSeparator4 = swing.JSeparator() 575 | self._jCheckHPP = swing.JCheckBox('Param Pollution') 576 | self._jCheckCU = swing.JCheckBox('Current User') 577 | self._jCheckDB = swing.JCheckBox('Current DB') 578 | self._jCheckHost = swing.JCheckBox('Hostname') 579 | self._jCheckDBA = swing.JCheckBox('Is DBA?') 580 | self._jCheckUsers = swing.JCheckBox('List Users') 581 | self._jCheckPrivs = swing.JCheckBox('List Privs') 582 | self._jCheckPswds = swing.JCheckBox('List Passwords') 583 | self._jCheckRoles = swing.JCheckBox('List Roles') 584 | self._jCheckDBs = swing.JCheckBox('List DBs') 585 | self._jSeparator5 = swing.JSeparator() 586 | self._jLabelThreads = swing.JLabel() 587 | self._jLabelDelay = swing.JLabel() 588 | self._jLabelTimeout = swing.JLabel() 589 | self._jLabelRetry = swing.JLabel() 590 | self._jLabelTimeSec = swing.JLabel() 591 | self._jComboThreads = swing.JComboBox(threadValues) 592 | self._jComboDelay = swing.JComboBox(delayValues) 593 | self._jComboTimeout = swing.JComboBox(timeoutValues) 594 | self._jComboRetry = swing.JComboBox(retryValues) 595 | self._jComboTimeSec = swing.JComboBox(timeSecValues) 596 | self._jSeparator6 = swing.JSeparator() 597 | self._jLabelDBMS = swing.JLabel() 598 | self._jComboDBMS = swing.JComboBox(dbmsValues) 599 | self._jLabelOS = swing.JLabel() 600 | self._jComboOS = swing.JComboBox(osValues) 601 | self._jSeparator7 = swing.JSeparator() 602 | self._jLabelProxy = swing.JLabel() 603 | self._jTextFieldProxy = swing.JTextField() 604 | self._jSeparator8 = swing.JSeparator() 605 | self._jLabelTamper = swing.JLabel() 606 | self._jTextFieldTamper = swing.JTextField() 607 | self._jButtonStartScan = swing.JButton('Start Scan', actionPerformed=self.startScan) 608 | self._jLabelScanAPI = swing.JLabel() 609 | self._jLabelScanAPI.setText('SQLMap API is NOT running!') 610 | self._jLabelScanAPI.setForeground(Color.RED) 611 | self._jSeparator9 = swing.JSeparator() 612 | self._jSeparator10 = swing.JSeparator() 613 | self._jCheckTor = swing.JCheckBox('Enable Tor') 614 | self._jLabelTorType = swing.JLabel() 615 | self._jComboTorType = swing.JComboBox(torTypes) 616 | self._jLabelTorPort = swing.JLabel() 617 | self._jTextFieldTorPort = swing.JTextField() 618 | self._jSeparator11 = swing.JSeparator() 619 | self._jLabelAuthType = swing.JLabel() 620 | self._jComboAuthType = swing.JComboBox(authTypes) 621 | self._jLabelAuthUser = swing.JLabel() 622 | self._jTextFieldAuthUser = swing.JTextField() 623 | self._jLabelAuthPass = swing.JLabel() 624 | self._jTextFieldAuthPass = swing.JTextField() 625 | self._jLabelTechnique = swing.JLabel() 626 | self._jTextFieldTechnique = swing.JTextField() 627 | 628 | # Configure GUI 629 | self._jLabelScanText.setText('API Listening On:') 630 | self._jLabelScanIPListen.setText('SQLMap API IP:') 631 | self._jLabelScanPortListen.setText('SQLMap API Port:') 632 | self._jLabelHttpMethod.setText('HTTP Method:') 633 | self._jLabelIgnoreCode.setText('Ignore Error Code:') 634 | self._jComboHttpMethod.setSelectedIndex(0) 635 | self._jLabelURL.setText('URL:') 636 | self._jLabelData.setText('Post Data:') 637 | self._jTextData.setLineWrap(True) 638 | self._jScrollPaneData.setVerticalScrollBarPolicy(swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS) 639 | self._jLabelCookie.setText('Cookies:') 640 | self._jLabelReferer.setText('Referer:') 641 | self._jLabelUA.setText('User-Agent:') 642 | self._jLabelCustHeader.setText('Extra Headers:') 643 | self._jLabelParam.setText('Test Parameter(s):') 644 | self._jCustHeadCheckParam.setText('Add Headers') 645 | self._jCheckTO.setText('Text Only') 646 | self._jLabelLevel.setText('Level:') 647 | self._jLabelRisk.setText('Risk:') 648 | self._jComboLevel.setSelectedIndex(2) 649 | self._jComboRisk.setSelectedIndex(1) 650 | self._jComboThreads.setSelectedIndex(0) 651 | self._jComboDelay.setSelectedIndex(0) 652 | self._jComboTimeout.setSelectedIndex(6) 653 | self._jComboRetry.setSelectedIndex(2) 654 | self._jComboTimeSec.setSelectedIndex(4) 655 | self._jComboDBMS.setSelectedIndex(0) 656 | self._jComboOS.setSelectedIndex(0) 657 | self._jComboTorType.setSelectedIndex(2) 658 | self._jLabelThreads.setText('Threads:') 659 | self._jLabelDelay.setText('Delay:') 660 | self._jLabelTimeout.setText('Timeout:') 661 | self._jLabelRetry.setText('Retries:') 662 | self._jLabelTimeSec.setText('Time-Sec:') 663 | self._jLabelDBMS.setText('DBMS Backend:') 664 | self._jLabelOS.setText('Operating System:') 665 | self._jLabelProxy.setText('Proxy (HTTP://IP:Port):') 666 | self._jLabelTamper.setText('Tamper Scripts:') 667 | self._jLabelTorType.setText('Tor Type:') 668 | self._jLabelTorPort.setText('Tor Port:') 669 | self._jTextFieldTorPort.setText('9050') 670 | self._jLabelAuthType.setText('Auth Type:') 671 | self._jLabelAuthUser.setText('Auth User:') 672 | self._jLabelAuthPass.setText('Auth Pass:') 673 | self._jComboAuthType.setSelectedIndex(0) 674 | self._jLabelTechnique.setText('Technique (BEUSTQ):') 675 | self._jTextFieldTechnique.setText('BEUSTQ') 676 | 677 | # Configure locations 678 | self._jLabelScanText.setBounds(15, 16, 126, 20) 679 | self._jLabelScanIPListen.setBounds(15, 58, 115, 20) 680 | self._jLabelScanPortListen.setBounds(402, 55, 129, 20) 681 | self._jTextFieldScanIPListen.setBounds(167, 52, 206, 26) 682 | self._jTextFieldScanPortListen.setBounds(546, 52, 63, 26) 683 | self._jSeparator1.setBounds(15, 96, 790, 10) 684 | self._jLabelHttpMethod.setBounds(15, 117, 100, 26) 685 | self._jLabelIgnoreCode.setBounds(402, 117, 129, 26) 686 | self._jComboHttpMethod.setBounds(166, 117, 150, 26) 687 | self._jTextFieldIgnoreCode.setBounds(546, 117, 63, 26) 688 | self._jLabelURL.setBounds(15, 193, 35, 20) 689 | self._jTextFieldURL.setBounds(166, 190, 535, 26) 690 | self._jLabelData.setBounds(15, 232, 73, 20) 691 | self._jScrollPaneData.setBounds(166, 232, 535, 96) 692 | self._jLabelCookie.setBounds(15, 347, 61, 20) 693 | self._jTextFieldCookie.setBounds(166, 347, 535, 26) 694 | self._jLabelReferer.setBounds(15, 396, 57, 20) 695 | self._jTextFieldReferer.setBounds(166, 396, 535, 26) 696 | self._jLabelUA.setBounds(15, 445, 86, 20) 697 | self._jTextFieldUA.setBounds(166, 445, 535, 26) 698 | self._jLabelCustHeader.setBounds(15, 494, 132, 20) 699 | self._jTextFieldCustHeader.setBounds(166, 494, 366, 26) 700 | self._jCustHeadCheckParam.setBounds(584, 494, 101, 29) 701 | self._jSeparator2.setBounds(15, 535, 790, 10) 702 | self._jLabelParam.setBounds(15, 559, 132, 20) 703 | self._jTextFieldParam.setBounds(165, 556, 366, 26) 704 | self._jCheckTO.setBounds(584, 555, 101, 29) 705 | self._jSeparator3.setBounds(15, 602, 790, 10) 706 | self._jLabelLevel.setBounds(15, 623, 120, 20) 707 | self._jComboLevel.setBounds(65, 620, 120, 26) 708 | self._jLabelRisk.setBounds(205, 623, 120, 20) 709 | self._jComboRisk.setBounds(245, 620, 120, 26) 710 | self._jLabelTechnique.setBounds(375, 620, 140, 26) 711 | self._jTextFieldTechnique.setBounds(510, 620, 120, 26) 712 | self._jSeparator4.setBounds(15, 664, 790, 10) 713 | self._jCheckHPP.setBounds(15, 684, 145, 29) 714 | self._jCheckCU.setBounds(191, 684, 123, 29) 715 | self._jCheckDB.setBounds(340, 684, 111, 29) 716 | self._jCheckHost.setBounds(469, 684, 103, 29) 717 | self._jCheckDBA.setBounds(599, 684, 105, 29) 718 | self._jCheckUsers.setBounds(15, 731, 101, 29) 719 | self._jCheckPswds.setBounds(191, 731, 135, 29) 720 | self._jCheckPrivs.setBounds(344, 731, 95, 29) 721 | self._jCheckRoles.setBounds(469, 731, 99, 29) 722 | self._jCheckDBs.setBounds(599, 731, 89, 29) 723 | self._jSeparator5.setBounds(15, 772, 790, 10) 724 | self._jLabelThreads.setBounds(15, 795, 63, 20) 725 | self._jLabelDelay.setBounds(173, 795, 45, 20) 726 | self._jLabelTimeout.setBounds(326, 795, 65, 20) 727 | self._jLabelRetry.setBounds(484, 795, 48, 20) 728 | self._jLabelTimeSec.setBounds(642, 795, 65, 20) 729 | self._jComboThreads.setBounds(80, 792, 78, 26) 730 | self._jComboDelay.setBounds(233, 792, 78, 26) 731 | self._jComboTimeout.setBounds(391, 792, 78, 26) 732 | self._jComboRetry.setBounds(549, 792, 78, 26) 733 | self._jComboTimeSec.setBounds(717, 792, 78, 26) 734 | self._jSeparator6.setBounds(15, 834, 790, 10) 735 | self._jLabelDBMS.setBounds(15, 857, 110, 20) 736 | self._jComboDBMS.setBounds(143, 854, 191, 26) 737 | self._jLabelOS.setBounds(352, 857, 132, 20) 738 | self._jComboOS.setBounds(502, 854, 191, 26) 739 | self._jSeparator7.setBounds(15, 896, 790, 10) 740 | self._jLabelProxy.setBounds(15, 920, 171, 20) 741 | self._jTextFieldProxy.setBounds(204, 917, 256, 26) 742 | self._jSeparator8.setBounds(15, 963, 790, 10) 743 | self._jCheckTor.setBounds(15, 987, 171, 20) 744 | self._jLabelTorType.setBounds(206, 984, 65, 26) 745 | self._jComboTorType.setBounds(291, 984, 100, 26) 746 | self._jLabelTorPort.setBounds(460, 984, 129, 26) 747 | self._jTextFieldTorPort.setBounds(545, 984, 65, 26) 748 | self._jSeparator9.setBounds(15, 1030, 790, 10) 749 | self._jLabelTamper.setBounds(15, 1055, 171, 20) 750 | self._jTextFieldTamper.setBounds(204, 1052, 256, 26) 751 | self._jSeparator10.setBounds(15, 1098, 790, 10) 752 | self._jLabelAuthType.setBounds(15, 1123, 171, 20) 753 | self._jComboAuthType.setBounds(204, 1123, 100, 26) 754 | self._jLabelAuthUser.setBounds(15, 1172, 171, 20) 755 | self._jTextFieldAuthUser.setBounds(204, 1172, 256, 26) 756 | self._jLabelAuthPass.setBounds(15, 1221, 171, 20) 757 | self._jTextFieldAuthPass.setBounds(204, 1221, 256, 26) 758 | self._jSeparator11.setBounds(15, 1267, 790, 10) 759 | self._jButtonStartScan.setBounds(346, 1292, 103, 29) 760 | self._jLabelScanAPI.setBounds(167, 16, 275, 20) 761 | 762 | # Create main panel 763 | self._jScanPanel = swing.JPanel() 764 | self._jScanPanel.setLayout(None) 765 | self._jScanPanel.setPreferredSize(awt.Dimension(1368,1368)) 766 | self._jScanPanel.add(self._jLabelScanText) 767 | self._jScanPanel.add(self._jLabelScanIPListen) 768 | self._jScanPanel.add(self._jLabelScanPortListen) 769 | self._jScanPanel.add(self._jTextFieldScanIPListen) 770 | self._jScanPanel.add(self._jTextFieldScanPortListen) 771 | self._jScanPanel.add(self._jSeparator1) 772 | self._jScanPanel.add(self._jLabelURL) 773 | self._jScanPanel.add(self._jTextFieldURL) 774 | self._jScanPanel.add(self._jLabelData) 775 | self._jScanPanel.add(self._jScrollPaneData) 776 | self._jScanPanel.add(self._jLabelCookie) 777 | self._jScanPanel.add(self._jTextFieldCookie) 778 | self._jScanPanel.add(self._jLabelReferer) 779 | self._jScanPanel.add(self._jTextFieldReferer) 780 | self._jScanPanel.add(self._jLabelHttpMethod) 781 | self._jScanPanel.add(self._jLabelIgnoreCode) 782 | self._jScanPanel.add(self._jComboHttpMethod) 783 | self._jScanPanel.add(self._jTextFieldIgnoreCode) 784 | self._jScanPanel.add(self._jLabelUA) 785 | self._jScanPanel.add(self._jTextFieldUA) 786 | self._jScanPanel.add(self._jLabelCustHeader) 787 | self._jScanPanel.add(self._jTextFieldCustHeader) 788 | self._jScanPanel.add(self._jCustHeadCheckParam) 789 | self._jScanPanel.add(self._jSeparator2) 790 | self._jScanPanel.add(self._jLabelParam) 791 | self._jScanPanel.add(self._jTextFieldParam) 792 | self._jScanPanel.add(self._jCheckTO) 793 | self._jScanPanel.add(self._jSeparator3) 794 | self._jScanPanel.add(self._jComboLevel) 795 | self._jScanPanel.add(self._jLabelLevel) 796 | self._jScanPanel.add(self._jLabelRisk) 797 | self._jScanPanel.add(self._jComboRisk) 798 | self._jScanPanel.add(self._jSeparator4) 799 | self._jScanPanel.add(self._jCheckHPP) 800 | self._jScanPanel.add(self._jCheckCU) 801 | self._jScanPanel.add(self._jCheckDB) 802 | self._jScanPanel.add(self._jCheckHost) 803 | self._jScanPanel.add(self._jCheckDBA) 804 | self._jScanPanel.add(self._jCheckUsers) 805 | self._jScanPanel.add(self._jCheckPswds) 806 | self._jScanPanel.add(self._jCheckPrivs) 807 | self._jScanPanel.add(self._jCheckRoles) 808 | self._jScanPanel.add(self._jCheckDBs) 809 | self._jScanPanel.add(self._jSeparator5) 810 | self._jScanPanel.add(self._jLabelThreads) 811 | self._jScanPanel.add(self._jLabelDelay) 812 | self._jScanPanel.add(self._jLabelTimeout) 813 | self._jScanPanel.add(self._jLabelRetry) 814 | self._jScanPanel.add(self._jLabelTimeSec) 815 | self._jScanPanel.add(self._jComboThreads) 816 | self._jScanPanel.add(self._jComboDelay) 817 | self._jScanPanel.add(self._jComboTimeout) 818 | self._jScanPanel.add(self._jComboRetry) 819 | self._jScanPanel.add(self._jComboTimeSec) 820 | self._jScanPanel.add(self._jSeparator6) 821 | self._jScanPanel.add(self._jLabelDBMS) 822 | self._jScanPanel.add(self._jComboDBMS) 823 | self._jScanPanel.add(self._jLabelOS) 824 | self._jScanPanel.add(self._jComboOS) 825 | self._jScanPanel.add(self._jSeparator7) 826 | self._jScanPanel.add(self._jLabelProxy) 827 | self._jScanPanel.add(self._jTextFieldProxy) 828 | self._jScanPanel.add(self._jSeparator8) 829 | self._jScanPanel.add(self._jCheckTor) 830 | self._jScanPanel.add(self._jLabelTorType) 831 | self._jScanPanel.add(self._jComboTorType) 832 | self._jScanPanel.add(self._jLabelTorPort) 833 | self._jScanPanel.add(self._jTextFieldTorPort) 834 | self._jScanPanel.add(self._jSeparator9) 835 | self._jScanPanel.add(self._jLabelTamper) 836 | self._jScanPanel.add(self._jTextFieldTamper) 837 | self._jScanPanel.add(self._jSeparator10) 838 | self._jScanPanel.add(self._jLabelAuthType) 839 | self._jScanPanel.add(self._jComboAuthType) 840 | self._jScanPanel.add(self._jLabelAuthUser) 841 | self._jScanPanel.add(self._jTextFieldAuthUser) 842 | self._jScanPanel.add(self._jLabelAuthPass) 843 | self._jScanPanel.add(self._jTextFieldAuthPass) 844 | self._jScanPanel.add(self._jSeparator11) 845 | self._jScanPanel.add(self._jButtonStartScan) 846 | self._jScanPanel.add(self._jLabelScanAPI) 847 | self._jScrollPaneMain = swing.JScrollPane(self._jScanPanel) 848 | self._jScanPanel.add(self._jLabelTechnique) 849 | self._jScanPanel.add(self._jTextFieldTechnique) 850 | self._jScrollPaneMain.setViewportView(self._jScanPanel) 851 | self._jScrollPaneMain.setPreferredSize(awt.Dimension(1357,1357)) 852 | 853 | # Create SQLMap log JPanel 854 | self._jLogPanel = swing.JPanel() 855 | self._jLogPanel.setLayout(None) 856 | 857 | # Create label, combobox, and button to get logs and textarea to display them 858 | self._jLabelLog = swing.JLabel("Logs for Scan ID:") 859 | self._jComboLogs = swing.JComboBox(self.scantasks) 860 | self._jButtonGetLogs = swing.JButton('Get', actionPerformed=self.getLogs) 861 | self._jButtonRemoveLogs = swing.JButton('Remove', actionPerformed=self.removeLogs) 862 | self._jTextLogs = swing.JTextArea() 863 | self._jTextLogs.setColumns(50) 864 | self._jTextLogs.setRows(50) 865 | self._jTextLogs.setLineWrap(True) 866 | self._jTextLogs.setEditable(False) 867 | self._jScrollPaneLogs = swing.JScrollPane(self._jTextLogs) 868 | self._jScrollPaneLogs.setVerticalScrollBarPolicy(swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS) 869 | 870 | self._jLabelLog.setBounds(15, 16, 126, 20) 871 | self._jComboLogs.setBounds(167, 16, 535, 20) 872 | self._jButtonGetLogs.setBounds(718, 16, 50, 20) 873 | self._jButtonRemoveLogs.setBounds(783, 16, 80, 20) 874 | self._jScrollPaneLogs.setBounds(15, 58, 846, 400) 875 | 876 | self._jLogPanel.add(self._jLabelLog) 877 | self._jLogPanel.add(self._jComboLogs) 878 | self._jLogPanel.add(self._jButtonGetLogs) 879 | self._jLogPanel.add(self._jButtonRemoveLogs) 880 | self._jLogPanel.add(self._jScrollPaneLogs) 881 | 882 | # Create SQLMap stop scan JPanel 883 | self._jStopScanPanel = swing.JPanel() 884 | self._jStopScanPanel.setLayout(None) 885 | 886 | # Create label, combobox, and button to stop scans and textfield to display success 887 | self._jLabelStopScan = swing.JLabel("Stop Scan ID:") 888 | self._jComboStopScan = swing.JComboBox(self.scantasks) 889 | self._jButtonStopScan = swing.JButton('Stop', actionPerformed=self.stopScan) 890 | self._jButtonRemoveScan = swing.JButton('Remove', actionPerformed=self.removeScan) 891 | self._jLabelStopStatus = swing.JLabel() 892 | 893 | self._jLabelStopScan.setBounds(15, 16, 126, 20) 894 | self._jComboStopScan.setBounds(167, 16, 535, 20) 895 | self._jButtonStopScan.setBounds(718, 16, 55, 20) 896 | self._jButtonRemoveScan.setBounds(783, 16, 80, 20) 897 | self._jLabelStopStatus.setBounds(167, 58, 846, 20) 898 | 899 | self._jStopScanPanel.add(self._jLabelStopScan) 900 | self._jStopScanPanel.add(self._jComboStopScan) 901 | self._jStopScanPanel.add(self._jButtonStopScan) 902 | self._jStopScanPanel.add(self._jButtonRemoveScan) 903 | self._jStopScanPanel.add(self._jLabelStopStatus) 904 | 905 | # Setup Tabs 906 | self._jConfigTab = swing.JTabbedPane() 907 | self._jConfigTab.addTab("SQLMap API", self._jPanel) 908 | self._jConfigTab.addTab("SQLMap Scanner", self._jScrollPaneMain) 909 | self._jConfigTab.addTab("SQLMap Logs", self._jLogPanel) 910 | self._jConfigTab.addTab("SQLMap Scan Stop", self._jStopScanPanel) 911 | 912 | # Automatically get and set the Python path if we can find it 913 | pythonpath = '' 914 | pythonregpath1 = '' 915 | pythonregpath2 = '' 916 | pathpart1 = '' 917 | pathpart2 = '' 918 | drivepart1 = '' 919 | drivepart2 = '' 920 | pythonaltpath1 = '' 921 | pythonaltpath2 = '' 922 | path_delim = '' 923 | ostype = System.getProperty('os.name') 924 | 925 | try: 926 | if 'Windows' in ostype: 927 | path_delim = '\\' 928 | 929 | try: 930 | pythonpath = subprocess.check_output(['where', 'python']).split('\n')[0].rstrip('\n\r') 931 | except: 932 | print 'Could not find python.exe in path.\n' 933 | 934 | try: 935 | pythonregpath1 = subprocess.check_output('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath" /ve') 936 | pathpart1 = pythonregpath1.rsplit(':', 1)[1].rstrip('\n\r') 937 | drivepart1 = pythonregpath1.rsplit(':', 1)[0][-1] 938 | except: 939 | print 'Could not find python path in registry at: HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath.\n' 940 | 941 | try: 942 | pythonregpath2 = subprocess.check_output('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Python\\PythonCore\\2.7\InstallPath" /ve') 943 | pathpart2 = pythonregpath2.rsplit(':', 1)[1].rstrip('\n\r') 944 | drivepart2 = pythonregpath2.rsplit(':', 1)[0][-1] 945 | except: 946 | print 'Could not find python path in registry at: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Python\\PythonCore\\2.7\InstallPath.\n' 947 | 948 | if re.search('[pP]ython', pathpart1): 949 | pythonaltpath1 = drivepart1 + ':' + pathpart1 + path_delim + 'python.exe' 950 | else: 951 | try: 952 | pythonregpath1 = subprocess.check_output('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore" /se #') 953 | match = re.findall("3\.\d", str(pythonregpath1)) 954 | pythonregpath1 = subprocess.check_output('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\' + match[0] + '\\InstallPath" /v ExecutablePath') 955 | pathpart1 = str(pythonregpath1).rsplit(':', 1)[1].rstrip('\n\r')[:-9] 956 | drivepart1 = str(pythonregpath1).rsplit(':', 1)[0][-1] 957 | except: 958 | print 'Could not find python path in registry at: HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.x\\InstallPath\\ExecutablePath.\n' 959 | 960 | if re.search('[pP]ython', pathpart1): 961 | pythonaltpath1 = drivepart1 + ':' + pathpart1 962 | 963 | if re.search('[pP]ython', pathpart2): 964 | pythonaltpath2 = drivepart2 + ':' + pathpart2 + path_delim + 'python.exe' 965 | else: 966 | try: 967 | pythonregpath2 = subprocess.check_output('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Python\\PythonCore" /se #') 968 | match = re.findall("3\.\d", str(pythonregpath1)) 969 | pythonregpath2 = subprocess.check_output('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Python\\PythonCore\\' + match[0] + '\\InstallPath" /v ExecutablePath') 970 | pathpart2 = str(pythonregpath1).rsplit(':', 1)[1].rstrip('\n\r')[:-9] 971 | drivepart2 = str(pythonregpath1).rsplit(':', 1)[0][-1] 972 | except: 973 | print 'Could not find python path in registry at: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Python\\PythonCore\\3.x\\InstallPath\\ExecutablePath.\n' 974 | 975 | if re.search('[pP]ython', pathpart2): 976 | pythonaltpath2 = drivepart2 + ':' + pathpart2 977 | else: 978 | path_delim = '/' 979 | 980 | try: 981 | pythonpath = subprocess.check_output(['which', 'python2.7']).split('\n')[0].rstrip('\n\r') 982 | except: 983 | print 'Could not find python2 in path.\n' 984 | 985 | if re.search('\/python2.7$', pythonpath) is None: 986 | try: 987 | pythonpath = subprocess.check_output(['which', 'python3']).split('\n')[0].rstrip('\n\r') 988 | except: 989 | print 'Could not find python3 in path.\n' 990 | 991 | except: 992 | print 'Could not get OS version, therefore could not find Python path\n' 993 | 994 | # Set python variables 995 | if re.search('python.exe', pythonpath) or re.search('\/python2.7$', pythonpath) or re.search('\/python3', pythonpath): 996 | self.pythonfile = pythonpath 997 | print 'Python found in system path at: ' + pythonpath + '\n' 998 | elif re.search('python.exe', pythonaltpath1): 999 | self.pythonfile = pythonaltpath1 1000 | print 'Python found in registry under HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7 or 3.x\\InstallPath at: ' + pythonaltpath1 + '\n' 1001 | elif re.search('python.exe', pythonaltpath2): 1002 | self.pythonfile = pythonaltpath2 1003 | print 'Python found in registry under HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Python\\PythonCore\\2.7 or 3.x\InstallPath at: ' + pythonaltpath2 + '\n' 1004 | else: 1005 | print 'Could not set the correct Python path.\n' 1006 | 1007 | # Get Python version to confirm 2.7.x or 3.x 1008 | if 'Windows' in ostype and re.search('python.exe', self.pythonfile): 1009 | try: 1010 | pythonver = subprocess.check_output(self.pythonfile + ' -c "import sys; print(str(sys.version_info[0]) + str(sys.version_info[1]))"') 1011 | if str(pythonver[:-2]) == '27' or re.search('3\d', str(pythonver[:-2])): 1012 | self._jLabelPython.setText('Python set to: ' + self.pythonfile) 1013 | else: 1014 | self.pythonfile = '' 1015 | print 'Wrong version of Python: ' + pythonver[0] + '.' + pythonver[1] + '\n' 1016 | except: 1017 | print 'Could not get Python version\n' 1018 | elif re.search('python2.7', self.pythonfile) or re.search('python3', self.pythonfile): 1019 | self._jLabelPython.setText('Python set to: ' + self.pythonfile) 1020 | else: 1021 | print 'Wrong version of Python or something went wrong.\n' 1022 | 1023 | # Automatically set the sqlmapapi, first unzip if the extension has never run 1024 | if os.path.isfile(os.getcwd() + path_delim + 'sqlmap.zip'): 1025 | 1026 | # Extract sqlmap 1027 | try: 1028 | with zipfile.ZipFile(os.getcwd() + path_delim + 'sqlmap.zip') as sqlmapzip: 1029 | sqlmapzip.extractall(os.getcwd() + path_delim) 1030 | 1031 | # Remove sqlmap zip file 1032 | os.remove(os.getcwd() + path_delim + 'sqlmap.zip') 1033 | 1034 | # Set API 1035 | if os.path.isfile(os.getcwd() + path_delim + 'sqlmap' + path_delim + 'sqlmapapi.py'): 1036 | self._jLabelAPI.setText('API set to: ' + os.getcwd() + path_delim + 'sqlmap' + path_delim + 'sqlmapapi.py') 1037 | self.apifile = os.getcwd() + path_delim + 'sqlmap' + path_delim + 'sqlmapapi.py' 1038 | print 'SQLMap API found at: ' + self.apifile + '\n' 1039 | else: 1040 | print 'Could not find SQLMap API file.\n' 1041 | except: 1042 | print 'Failed to extract sqlmap.zip\n' 1043 | else: 1044 | # Set API 1045 | if os.path.isfile(os.getcwd() + path_delim + 'sqlmap' + path_delim + 'sqlmapapi.py'): 1046 | self._jLabelAPI.setText('API set to: ' + os.getcwd() + path_delim + 'sqlmap' + path_delim + 'sqlmapapi.py') 1047 | self.apifile = os.getcwd() + path_delim + 'sqlmap' + path_delim + 'sqlmapapi.py' 1048 | print 'SQLMap API found at: ' + self.apifile + '\n' 1049 | else: 1050 | print 'Could not find SQLMap API file.\n' 1051 | 1052 | callbacks.customizeUiComponent(self._jConfigTab) 1053 | callbacks.addSuiteTab(self) 1054 | return 1055 | 1056 | # Create a menu item if the appropriate section of the UI is selected 1057 | def createMenuItems(self, invocation): 1058 | menu = [] 1059 | 1060 | # Which part of the interface the user selects 1061 | ctx = invocation.getInvocationContext() 1062 | 1063 | # Message Viewer Req will show menu item if selected by the user 1064 | if ctx == 0 or ctx == 2: 1065 | menu.append(swing.JMenuItem("SQLiPy Scan", None, actionPerformed=lambda x, inv=invocation: self.sqlMapScan(inv))) 1066 | 1067 | return menu if menu else None 1068 | 1069 | def getTabCaption(self): 1070 | return 'SQLiPy' 1071 | 1072 | def getUiComponent(self): 1073 | return self._jConfigTab 1074 | 1075 | def sqlMapScan(self, invocation): 1076 | 1077 | # Check initial message for proper request/response and set variables - Burp will not return valid info otherwise 1078 | try: 1079 | invMessage = invocation.getSelectedMessages() 1080 | message = invMessage[0] 1081 | reqInfo = self._helpers.analyzeRequest(message) 1082 | reqUrl = str(reqInfo.getUrl()) 1083 | reqBody = message.getRequest() 1084 | bodyData = self._helpers.bytesToString(reqBody[reqInfo.getBodyOffset():]) 1085 | reqHeaders = newHeaders = list(reqInfo.getHeaders()) 1086 | referer = '' 1087 | ua = '' 1088 | cookie = '' 1089 | headerString = '' 1090 | 1091 | for header in reqHeaders: 1092 | if re.search('^Referer', header, re.IGNORECASE) is not None: 1093 | referer = re.sub('^Referer\:\s+', '', header, re.IGNORECASE) 1094 | elif re.search('^User-Agent', header, re.IGNORECASE) is not None: 1095 | ua = re.sub('^User-Agent\:\s+', '', header, re.IGNORECASE) 1096 | elif re.search('^Cookie', header, re.IGNORECASE) is not None: 1097 | cookie = re.sub('^Cookie\:\s+', '', header, re.IGNORECASE) 1098 | elif ':' in header: 1099 | headerString += ("\\n" if headerString != "" else "") + header 1100 | 1101 | self._jTextFieldURL.setText(reqUrl) 1102 | self._jTextData.setText(bodyData) 1103 | self._jTextFieldCookie.setText(cookie) 1104 | self._jTextFieldUA.setText(ua) 1105 | self._jTextFieldReferer.setText(referer) 1106 | self._jTextFieldCustHeader.setText(headerString) 1107 | self._jConfigTab.setSelectedComponent(self._jScrollPaneMain) 1108 | self.scanMessage = message 1109 | self.scanUrl = reqInfo.getUrl() 1110 | parentTab = self._jConfigTab.getParent() 1111 | parentTab.setSelectedComponent(self._jConfigTab) 1112 | except: 1113 | print 'Failed to add data to scan tab.' 1114 | 1115 | def printHeader(self): 1116 | print 'SQLiPy - 0.8.6\nBurp interface to SQLMap via the SQLMap API\njosh.berry@codewatch.org\n\n' 1117 | 1118 | def setAPI(self, e): 1119 | selectFile = swing.JFileChooser() 1120 | filter = swing.filechooser.FileNameExtensionFilter("python files", ["py"]) 1121 | selectFile.addChoosableFileFilter(filter) 1122 | 1123 | returnedFile = selectFile.showDialog(self._jPanel, "SQLMap API") 1124 | 1125 | if returnedFile == swing.JFileChooser.APPROVE_OPTION: 1126 | file = selectFile.getSelectedFile() 1127 | self.apifile = file.getPath() 1128 | print 'Selected API at ' + file.getPath() 1129 | self._jLabelAPI.setText('API set to: ' + file.getPath()) 1130 | 1131 | def setPython(self, e): 1132 | selectFile = swing.JFileChooser() 1133 | 1134 | returnedFile = selectFile.showDialog(self._jPanel, "Python EXE") 1135 | 1136 | if returnedFile == swing.JFileChooser.APPROVE_OPTION: 1137 | file = selectFile.getSelectedFile() 1138 | self.pythonfile = file.getPath() 1139 | print 'Selected Python at ' + file.getPath() 1140 | self._jLabelPython.setText('Python set to: ' + file.getPath()) 1141 | 1142 | def startAPI(self, button): 1143 | if self.apistatus == 0: 1144 | try: 1145 | print 'Calling: ' + self.pythonfile + ' ' + self.apifile + ' -s -H ' + self._jTextFieldIPListen.getText() + ' -p ' + self._jTextFieldPortListen.getText() + '\n' 1146 | sqlmapdir = '' 1147 | 1148 | if re.search('^[a-zA-Z]\:', self.apifile) is not None: 1149 | sqlmapdir = self.apifile.rsplit('\\', 1)[0] 1150 | else: 1151 | sqlmapdir = self.apifile.rsplit('/', 1)[0] 1152 | 1153 | javaexec = getattr(Runtime.getRuntime(), "exec") 1154 | cmd = [self.pythonfile, self.apifile, "-s", "-H", self._jTextFieldIPListen.getText(), "-p", self._jTextFieldPortListen.getText()] 1155 | 1156 | self.apiprocess = javaexec(cmd, None, File(sqlmapdir)) 1157 | 1158 | self.errorGobbler = Thread(StreamGobbler(self.apiprocess.getErrorStream(), System.err)) 1159 | self.outputGobbler = Thread(StreamGobbler(self.apiprocess.getInputStream(), System.out)) 1160 | 1161 | self.errorGobbler.start() 1162 | self.outputGobbler.start() 1163 | 1164 | # Final validation the API is running 1165 | try: 1166 | time.sleep(5) 1167 | req = urllib2.Request('http://' + str(self._jTextFieldIPListen.getText()) + ':' + str(self._jTextFieldPortListen.getText()) + '/scan/0/status') 1168 | req.add_header('Content-Type', 'application/json') 1169 | resp = json.load(urllib2.urlopen(req, timeout=10)) 1170 | 1171 | if resp['message'] == "Invalid task ID": 1172 | self._jLabelScanAPI.setText(self._jTextFieldIPListen.getText() + ':' + self._jTextFieldPortListen.getText()) 1173 | self._jLabelScanAPI.setForeground(Color.GREEN) 1174 | self._jTextFieldScanIPListen.setText(self._jTextFieldIPListen.getText()) 1175 | self._jTextFieldScanPortListen.setText(self._jTextFieldPortListen.getText()) 1176 | self._jLabelAPIStatus.setText('SQLMap API IS CURRENTLY RUNNING!') 1177 | self._jLabelAPIStatus.setForeground(Color.GREEN) 1178 | self.apistatus = 1 1179 | 1180 | print 'SQLMap API started.\n' 1181 | except: 1182 | self.apiprocess.destroy() 1183 | self.errorGobbler.join() 1184 | self.outputGobbler.join() 1185 | print 'Failed to start the SQLMap API\n' 1186 | 1187 | except: 1188 | print 'Failed to start the SQLMap API\n' 1189 | else: 1190 | print 'The SQLMap API process has already been started\n' 1191 | 1192 | def stopAPI(self, button): 1193 | if self.apistatus == 1: 1194 | try: 1195 | if self._jComboStopScan.getItemCount() is not 0: 1196 | for item in range(0, self._jComboStopScan.getItemCount()): 1197 | req = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/scan/' + str(self._jComboStopScan.getItemAt(item).split('-')[0]) + '/kill') 1198 | resp = json.load(urllib2.urlopen(req, timeout=3)) 1199 | 1200 | if resp['success'] == True: 1201 | print 'Scan stopped for ID: '+ self._jComboStopScan.getItemAt(item).split('-')[0]+'\n' 1202 | else: 1203 | print 'Failed to stop scan on ID: '+self._jComboStopScan.getItemAt(item).split('-')[0]+', likely already completed\n' 1204 | 1205 | except: 1206 | print 'Failed to stop currently running SQLMap scans or no scans were still running\n' 1207 | 1208 | try: 1209 | totalThreads = 1 1210 | 1211 | for thread in self.threads: 1212 | print 'Stopping running scan check thread: ' + str(totalThreads) + '\n' 1213 | totalThreads += 1 1214 | thread.keep_running = False 1215 | thread.join() 1216 | 1217 | i = 0 1218 | while i < len(self.threads): 1219 | self.threads.pop(0) 1220 | i += 1 1221 | 1222 | except: 1223 | print 'Could not stop running threads\n' 1224 | 1225 | try: 1226 | self.apiprocess.destroy() 1227 | self._jComboLogs.removeAllItems() 1228 | self._jComboStopScan.removeAllItems() 1229 | self._jLabelScanAPI.setText('SQLMap API is NOT running!') 1230 | self._jLabelScanAPI.setForeground(Color.RED) 1231 | self._jLabelAPIStatus.setText('SQLMap API is NOT running!') 1232 | self._jLabelAPIStatus.setForeground(Color.RED) 1233 | self.apistatus = 0 1234 | 1235 | print 'Stopping the SQLMap API\n' 1236 | except: 1237 | print 'Failed to stop the SQLMap API\n' 1238 | 1239 | try: 1240 | self.errorGobbler.join() 1241 | self.outputGobbler.join() 1242 | 1243 | print 'Stopping API input/output/error buffers threads\n' 1244 | except: 1245 | print 'Failed to stop API input/output/error buffers threads\n' 1246 | 1247 | def extensionUnloaded(self): 1248 | if self.apistatus == 1: 1249 | try: 1250 | if self._jComboStopScan.getItemCount() is not 0: 1251 | for item in range(0, self._jComboStopScan.getItemCount()): 1252 | req = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/scan/' + str(self._jComboStopScan.getItemAt(item).split('-')[0]) + '/kill') 1253 | resp = json.load(urllib2.urlopen(req, timeout=3)) 1254 | 1255 | if resp['success'] == True: 1256 | print 'Scan stopped for ID: '+ self._jComboStopScan.getItemAt(item).split('-')[0]+'\n' 1257 | else: 1258 | print 'Failed to stop scan on ID: '+self._jComboStopScan.getItemAt(item).split('-')[0]+', likely already completed\n' 1259 | 1260 | except: 1261 | print 'Failed to stop currently running SQLMap scans or no scans were still running\n' 1262 | 1263 | try: 1264 | totalThreads = 1 1265 | 1266 | for thread in self.threads: 1267 | print 'Stopping running scan check thread: ' + str(totalThreads) + '\n' 1268 | totalThreads += 1 1269 | thread.keep_running = False 1270 | thread.join() 1271 | 1272 | except: 1273 | print 'Could not stop running threads\n' 1274 | 1275 | try: 1276 | self.apiprocess.destroy() 1277 | print 'Stopping the SQLMap API...\n' 1278 | except: 1279 | print 'Failed to stop the SQLMap API\n' 1280 | 1281 | try: 1282 | self.errorGobbler.join() 1283 | self.outputGobbler.join() 1284 | 1285 | print 'Stopping API input/output/error buffers threads\n' 1286 | except: 1287 | print 'Failed to stop API input/output/error buffers threads\n' 1288 | 1289 | def getLogs(self, button): 1290 | try: 1291 | req = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/scan/' + str(self._jComboLogs.getSelectedItem().split('-')[0]) + '/log') 1292 | resp = json.load(urllib2.urlopen(req, timeout=10)) 1293 | 1294 | if resp['success'] == True: 1295 | logdata = '' 1296 | for logs in resp['log']: 1297 | logdata = logdata + logs['level'] + ': ' + logs['time'] + ' - ' + logs['message'] + '\n' 1298 | 1299 | self._jTextLogs.setText('Log results for: ' + self.scancmds[self._jComboLogs.getSelectedItem().split('-')[0]] + logdata) 1300 | else: 1301 | print 'Failed to get logs for: '+self._jComboLogs.getSelectedItem().split('-')[0]+'\n' 1302 | except: 1303 | print 'Failed to get logs for: '+self._jComboLogs.getSelectedItem().split('-')[0]+'\n' 1304 | 1305 | def removeLogs(self, button): 1306 | print 'Removing Log Entry for ID: '+ self._jComboLogs.getSelectedItem().split('-')[0]+'\n' 1307 | self._jComboLogs.removeItem(self._jComboLogs.getSelectedItem()) 1308 | 1309 | def stopScan(self, button): 1310 | try: 1311 | req = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/scan/' + str(self._jComboStopScan.getSelectedItem().split('-')[0]) + '/kill') 1312 | resp = json.load(urllib2.urlopen(req, timeout=10)) 1313 | 1314 | if resp['success'] == True: 1315 | print 'Scan stopped for ID: '+ self._jComboStopScan.getSelectedItem().split('-')[0]+'\n' 1316 | self._jLabelStopStatus.setText('Scan stopped for ID: ' + self._jComboStopScan.getSelectedItem().split('-')[0]) 1317 | self._jComboStopScan.removeItem(self._jComboStopScan.getSelectedItem()) 1318 | else: 1319 | print 'Failed to stop scan on ID: '+self._jComboStopScan.getSelectedItem().split('-')[0]+', likely already completed\n' 1320 | self._jLabelStopStatus.setText('Failed to stop scan on ID: '+self._jComboStopScan.getSelectedItem().split('-')[0]+', likely already completed') 1321 | except: 1322 | print 'Failed to stop scan on ID: '+self._jComboStopScan.getSelectedItem().split('-')[0]+', likely already completed\n' 1323 | self._jLabelStopStatus.setText('Failed to stop scan on ID: '+self._jComboStopScan.getSelectedItem().split('-')[0]+', likely already completed') 1324 | 1325 | def removeScan(self, button): 1326 | print 'Removing Scan Stop Entry for ID: '+ self._jComboStopScan.getSelectedItem().split('-')[0]+'\n' 1327 | self._jLabelStopStatus.setText('Scan removed from stop tab for ID: ' + self._jComboStopScan.getSelectedItem().split('-')[0]) 1328 | self._jComboStopScan.removeItem(self._jComboStopScan.getSelectedItem()) 1329 | 1330 | def startScan(self, button): 1331 | hpp = '' 1332 | cu = '' 1333 | cdb = '' 1334 | hostname = '' 1335 | isdba = '' 1336 | lusers = '' 1337 | lpswds = '' 1338 | lprivs = '' 1339 | lroles = '' 1340 | ldbs = '' 1341 | textonly = '' 1342 | postdata = None 1343 | datacmd = '' 1344 | cookiedata = None 1345 | cookiecmd = '' 1346 | uadata = None 1347 | uacmd = '' 1348 | ignorecodedata = None 1349 | ignorecodecmd = '' 1350 | custheaderdata = None 1351 | custheadercmd = '' 1352 | headerdata = None 1353 | headercmd = '' 1354 | refererdata = None 1355 | referercmd = '' 1356 | proxy = None 1357 | proxycmd = '' 1358 | dbms = None 1359 | dbmscmd = '' 1360 | os = None 1361 | oscmd = '' 1362 | tampercmd = '' 1363 | tamperdata = None 1364 | paramcmd = '' 1365 | paramdata = None 1366 | csrfurl = None 1367 | csrftoken = None 1368 | torcmd = '' 1369 | tortypecmd = '' 1370 | torportcmd = '' 1371 | httpmethod = None 1372 | httpmethodcmd = '' 1373 | authtype = None 1374 | authtypecmd = '' 1375 | authcred = None 1376 | authcredcmd = '' 1377 | livecookies = None 1378 | skipheuristics = None 1379 | proxyfreq = None 1380 | 1381 | if self._jCheckTO.isSelected(): 1382 | textonly = ' --text-only' 1383 | textonlystatus = True 1384 | else: 1385 | textonlystatus = False 1386 | 1387 | if self._jCheckHPP.isSelected(): 1388 | hpp = ' --hpp' 1389 | hppstatus = True 1390 | else: 1391 | hppstatus = False 1392 | 1393 | if self._jCheckCU.isSelected(): 1394 | cu = ' --current-user' 1395 | custatus = True 1396 | else: 1397 | custatus = False 1398 | 1399 | if self._jCheckDB.isSelected(): 1400 | cdb = ' --current-db' 1401 | cdbstatus = True 1402 | else: 1403 | cdbstatus = False 1404 | 1405 | if self._jCheckHost.isSelected(): 1406 | hostname = ' --hostname' 1407 | hostnamestatus = True 1408 | else: 1409 | hostnamestatus = False 1410 | 1411 | if self._jCheckDBA.isSelected(): 1412 | isdba = ' --is-dba' 1413 | isdbastatus = True 1414 | else: 1415 | isdbastatus = False 1416 | 1417 | if self._jCheckUsers.isSelected(): 1418 | lusers = ' --users' 1419 | lusersstatus = True 1420 | else: 1421 | lusersstatus = False 1422 | 1423 | if self._jCheckPswds.isSelected(): 1424 | lpswds = ' --passwords' 1425 | lpswdsstatus = True 1426 | else: 1427 | lpswdsstatus = False 1428 | 1429 | if self._jCheckPrivs.isSelected(): 1430 | lprivs = ' --privileges' 1431 | lprivsstatus = True 1432 | else: 1433 | lprivsstatus = False 1434 | 1435 | if self._jCheckRoles.isSelected(): 1436 | lroles = ' --roles' 1437 | lrolesstatus = True 1438 | else: 1439 | lrolesstatus = False 1440 | 1441 | if self._jCheckDBs.isSelected(): 1442 | ldbs = ' --dbs' 1443 | ldbsstatus = True 1444 | else: 1445 | ldbsstatus = False 1446 | 1447 | if self._jCheckTor.isSelected(): 1448 | torstatus = True 1449 | torcmd = ' --tor' 1450 | tortype = self._jComboTorType.getSelectedItem() 1451 | tortypecmd = ' --tor-type=' + self._jComboTorType.getSelectedItem() 1452 | torport = self._jTextFieldTorPort.getText() 1453 | torportcmd = ' --tor-port=' + self._jTextFieldTorPort.getText() 1454 | else: 1455 | torstatus = False 1456 | tortype = 'HTTP' 1457 | torport = None 1458 | 1459 | if not re.search('^None$', self._jComboAuthType.getSelectedItem()) is not None and re.search('[a-zA-Z0-9]', self._jTextFieldAuthUser.getText()) is not None: 1460 | authtype = self._jComboAuthType.getSelectedItem() 1461 | authtypecmd = ' --auth-type=' + self._jComboAuthType.getSelectedItem() 1462 | authuser = self._jTextFieldAuthUser.getText() 1463 | authpass = self._jTextFieldAuthPass.getText() 1464 | authcred = authuser + ':' + authpass 1465 | authcredcmd = ' --auth-cred="' + authuser + ':' + authpass + '"' 1466 | else: 1467 | authtype = None 1468 | authtypecmd = '' 1469 | authuser = '' 1470 | authpass = '' 1471 | authcred = None 1472 | authcredcmd = '' 1473 | 1474 | if re.search('[a-zA-Z0-9]', self._jTextFieldIgnoreCode.getText()) is not None: 1475 | ignorecodedata = self._jTextFieldIgnoreCode.getText() 1476 | ignorecodecmd = ' --ignore-code=' + self._jTextFieldIgnoreCode.getText() 1477 | 1478 | if re.search('(http|https)\://', self._jTextFieldProxy.getText()) is not None: 1479 | proxy = self._jTextFieldProxy.getText() 1480 | proxycmd = ' --proxy=' + self._jTextFieldProxy.getText() 1481 | 1482 | if not re.search('^Default$', self._jComboHttpMethod.getSelectedItem()) is not None: 1483 | httpmethod = self._jComboHttpMethod.getSelectedItem() 1484 | httpmethodcmd = ' --method="' + self._jComboHttpMethod.getSelectedItem()+'"' 1485 | 1486 | if not re.search('^Any$', self._jComboDBMS.getSelectedItem()) is not None: 1487 | dbms = self._jComboDBMS.getSelectedItem() 1488 | dbmscmd = ' --dbms="' + self._jComboDBMS.getSelectedItem()+'"' 1489 | 1490 | if not re.search('^Any$', self._jComboOS.getSelectedItem()) is not None: 1491 | os = self._jComboOS.getSelectedItem() 1492 | oscmd = ' --os=' + self._jComboOS.getSelectedItem() 1493 | 1494 | if re.search('[a-zA-Z0-9]', self._jTextFieldTamper.getText()) is not None: 1495 | tampercmd = ' --tamper="' + self._jTextFieldTamper.getText() + '"' 1496 | tamperdata = self._jTextFieldTamper.getText() 1497 | 1498 | if re.search('[a-zA-Z0-9]', self._jTextData.getText()) is not None: 1499 | postdata = self._jTextData.getText() 1500 | datacmd = ' --data="' + self._jTextData.getText() + '"' 1501 | 1502 | if re.search('[a-zA-Z0-9]', self._jTextFieldCookie.getText()) is not None: 1503 | cookiedata = self._jTextFieldCookie.getText() 1504 | cookiecmd = ' --cookie="' + self._jTextFieldCookie.getText() + '"' 1505 | 1506 | if re.search('[a-zA-Z0-9]', self._jTextFieldUA.getText()) is not None: 1507 | uadata = self._jTextFieldUA.getText() 1508 | uacmd = ' --user-agent="' + self._jTextFieldUA.getText() + '"' 1509 | 1510 | if re.search('[a-zA-Z0-9]', self._jTextFieldCustHeader.getText()) is not None and self._jCustHeadCheckParam.isSelected(): 1511 | custheaderdata = self._jTextFieldCustHeader.getText() 1512 | custheadercmd = ' --headers="' + self._jTextFieldCustHeader.getText() + '"' 1513 | 1514 | if re.search('[a-zA-Z0-9]', self._jTextFieldReferer.getText()) is not None: 1515 | refererdata = self._jTextFieldReferer.getText() 1516 | referercmd = ' --referer="' + self._jTextFieldReferer.getText() + '"' 1517 | 1518 | if re.search('[a-zA-Z0-9]', self._jTextFieldParam.getText()) is not None: 1519 | paramdata = self._jTextFieldParam.getText() 1520 | paramcmd = ' -p "' + self._jTextFieldParam.getText() + '"' 1521 | 1522 | try: 1523 | sqlmapcmd = 'sqlmap.py -u "' + self._jTextFieldURL.getText() + '"' + datacmd + httpmethodcmd + cookiecmd + uacmd + referercmd + custheadercmd + authtypecmd + authcredcmd + ignorecodecmd + proxycmd + torcmd + tortypecmd + torportcmd + ' --delay=' + str(self._jComboDelay.getSelectedItem()) + ' --timeout=' + str(self._jComboTimeout.getSelectedItem()) + ' --retries=' + str(self._jComboDelay.getSelectedItem()) + paramcmd + dbmscmd + oscmd + tampercmd + ' --level=' + str(self._jComboLevel.getSelectedItem()) + ' --risk=' + str(self._jComboRisk.getSelectedItem()) + textonly + hpp + ' --threads=' + str(self._jComboThreads.getSelectedItem()) + ' --time-sec=' + str(self._jComboTimeSec.getSelectedItem()) + ' --technique=' + str(self._jTextFieldTechnique.getText()) + ' -b' + cu + cdb + hostname + isdba + lusers + lpswds + lprivs + lroles + ldbs + ' --batch --answers="crack=N,dict=N,continue=Y,quit=N"\n\n' 1524 | print 'SQLMap Command: ' + sqlmapcmd 1525 | url = 'http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/task/new' 1526 | req = urllib2.urlopen(url, timeout=10) 1527 | resp = json.loads(req.read()) 1528 | 1529 | if resp['success'] == True and resp['taskid']: 1530 | sqlitask = str(resp['taskid']) 1531 | sqliopts = {'authType': authtype, 'csrfUrl': csrfurl, 'csrfToken': csrftoken, 'liveCookies': livecookies, 'skipHeuristics': skipheuristics, 'proxyFreq': proxyfreq, 'getUsers': lusersstatus, 'getPasswordHashes': lpswdsstatus, 'delay': self._jComboDelay.getSelectedItem(), 'isDba': isdbastatus, 'risk': self._jComboRisk.getSelectedItem(), 'getCurrentUser': custatus, 'getRoles': lrolesstatus, 'getPrivileges': lprivsstatus, 'testParameter': paramdata, 'timeout': self._jComboTimeout.getSelectedItem(), 'ignoreCode': ignorecodedata, 'torPort': torport, 'level': self._jComboLevel.getSelectedItem(), 'technique': self._jTextFieldTechnique.getText(), 'getCurrentDb': cdbstatus, 'answers': 'crack=N,dict=N,continue=Y,quit=N', 'method': httpmethod, 'cookie': cookiedata, 'proxy': proxy, 'os': os, 'threads': self._jComboThreads.getSelectedItem(), 'url': self._jTextFieldURL.getText(), 'getDbs': ldbsstatus, 'tor': torstatus, 'torType': tortype, 'referer': refererdata, 'retries': self._jComboRetry.getSelectedItem(), 'headers': custheaderdata, 'authCred': authcred, 'timeSec': self._jComboTimeSec.getSelectedItem(), 'getHostname': hostnamestatus, 'agent': uadata, 'dbms': dbms, 'tamper': tamperdata, 'hpp': hppstatus, 'getBanner': 'true', 'data': postdata, 'textOnly': textonlystatus} 1532 | 1533 | print 'Created SQLMap Task: ' + sqlitask + '\n' 1534 | 1535 | try: 1536 | req = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/option/' + sqlitask + '/set') 1537 | req.add_header('Content-Type', 'application/json') 1538 | resp = json.load(urllib2.urlopen(req, json.dumps(sqliopts), timeout=10)) 1539 | 1540 | if resp['success'] == True: 1541 | print 'SQLMap options set on Task ' + sqlitask + ': ' + json.dumps(sqliopts) + '\n' 1542 | sqliopts = {'url': self._jTextFieldURL.getText()} 1543 | 1544 | try: 1545 | checkreq = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/option/' + sqlitask + '/list') 1546 | checkresp = json.load(urllib2.urlopen(checkreq, timeout=10)) 1547 | print 'SQLMap options returned: ' + json.dumps(checkresp) + '\n' 1548 | except: 1549 | print 'Failed to get list of options from SQLMap API\n' 1550 | 1551 | try: 1552 | req = urllib2.Request('http://' + str(self._jTextFieldScanIPListen.getText()) + ':' + str(self._jTextFieldScanPortListen.getText()) + '/scan/' + sqlitask + '/start') 1553 | req.add_header('Content-Type', 'application/json') 1554 | resp = json.load(urllib2.urlopen(req, json.dumps(sqliopts), timeout=10)) 1555 | 1556 | if resp['success'] == True: 1557 | findings = ThreadExtender(self, self._jTextFieldScanIPListen.getText(), self._jTextFieldScanPortListen.getText(), sqlitask, self.scanUrl, self.scanMessage, self._callbacks) 1558 | t = threading.Thread(target=findings.checkResults) 1559 | self.threads.append(t) 1560 | t.start() 1561 | self._jComboLogs.addItem(sqlitask + '-' + self._jTextFieldURL.getText()) 1562 | self._jComboStopScan.addItem(sqlitask + '-' + self._jTextFieldURL.getText()) 1563 | self.scancmds[sqlitask] = sqlmapcmd 1564 | print 'Started SQLMap Scan on Task ' + sqlitask +' with Engine ID: ' + str(resp['engineid']) + ' - ' + self._jTextFieldURL.getText() + '\n' 1565 | else: 1566 | print 'Failed to start SQLMap Scan for Task: ' + sqlitask + '\n' 1567 | 1568 | except: 1569 | print 'Failed to start SQLMap Scan for Task: ' + sqlitask + '\n' 1570 | 1571 | else: 1572 | print 'Failed to set options on SQLMap Task: ' + sqlitask + '\n' 1573 | 1574 | except: 1575 | print 'Failed to set options on SQLMap Task: ' + sqlitask + '\n' 1576 | 1577 | else: 1578 | print(traceback.format_exc()) 1579 | print 'SQLMap task creation failed\n' 1580 | 1581 | except: 1582 | print(traceback.format_exc()) 1583 | print 'SQLMap task creation failed\n' -------------------------------------------------------------------------------- /sqlmap.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewatchorg/sqlipy/940900693ea760864695cd04bddbca758d5336e0/sqlmap.zip --------------------------------------------------------------------------------