├── .gitignore ├── ElasticBurp.py ├── LICENSE ├── README.md ├── WASEHTMLParser.py ├── WASEProxy.py ├── WASEQuery.py ├── doc_HttpRequestResponse.py ├── queries.txt ├── requirements-proxy.txt ├── requirements.txt ├── test.py └── waseproxy.service /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.class 3 | *.pyc 4 | -------------------------------------------------------------------------------- /ElasticBurp.py: -------------------------------------------------------------------------------- 1 | # ElasticBurp 2 | # Copyright 2016 Thomas Patzke 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | from burp import IBurpExtender, IBurpExtenderCallbacks, IHttpListener, IRequestInfo, IParameter, IContextMenuFactory, ITab 18 | from javax.swing import JMenuItem, ProgressMonitor, JPanel, BoxLayout, JLabel, JTextField, JCheckBox, JButton, Box, JOptionPane 19 | from java.awt import Dimension 20 | from elasticsearch_dsl.connections import connections 21 | from elasticsearch_dsl import Index 22 | from elasticsearch.helpers import bulk 23 | from doc_HttpRequestResponse import DocHTTPRequestResponse 24 | from datetime import datetime 25 | from email.utils import parsedate_tz, mktime_tz 26 | from tzlocal import get_localzone 27 | import re 28 | 29 | try: 30 | tz = get_localzone() 31 | except: 32 | tz = None 33 | reDateHeader = re.compile("^Date:\s*(.*)$", flags=re.IGNORECASE) 34 | 35 | ### Config (TODO: move to config tab) ### 36 | ES_host = "localhost" 37 | ES_index = "wase-burp" 38 | Burp_Tools = IBurpExtenderCallbacks.TOOL_PROXY 39 | Burp_onlyResponses = True # Usually what you want, responses also contain requests 40 | ######################################### 41 | 42 | class BurpExtender(IBurpExtender, IHttpListener, IContextMenuFactory, ITab): 43 | def registerExtenderCallbacks(self, callbacks): 44 | self.callbacks = callbacks 45 | self.helpers = callbacks.getHelpers() 46 | callbacks.setExtensionName("Storing HTTP Requests/Responses into ElasticSearch") 47 | self.callbacks.registerHttpListener(self) 48 | self.callbacks.registerContextMenuFactory(self) 49 | self.out = callbacks.getStdout() 50 | 51 | self.lastTimestamp = None 52 | self.confESHost = self.callbacks.loadExtensionSetting("elasticburp.host") or ES_host 53 | self.confESIndex = self.callbacks.loadExtensionSetting("elasticburp.index") or ES_index 54 | self.confBurpTools = int(self.callbacks.loadExtensionSetting("elasticburp.tools") or Burp_Tools) 55 | saved_onlyresp = self.callbacks.loadExtensionSetting("elasticburp.onlyresp") 56 | if saved_onlyresp == "True": 57 | self.confBurpOnlyResp = True 58 | elif saved_onlyresp == "False": 59 | self.confBurpOnlyResp = False 60 | else: 61 | self.confBurpOnlyResp = bool(int(saved_onlyresp or Burp_onlyResponses)) 62 | 63 | self.callbacks.addSuiteTab(self) 64 | self.applyConfig() 65 | 66 | def applyConfig(self): 67 | try: 68 | print("Connecting to '%s', index '%s'" % (self.confESHost, self.confESIndex)) 69 | self.es = connections.create_connection(hosts=[self.confESHost]) 70 | self.idx = Index(self.confESIndex) 71 | self.idx.doc_type(DocHTTPRequestResponse) 72 | if self.idx.exists(): 73 | self.idx.open() 74 | else: 75 | self.idx.create() 76 | self.callbacks.saveExtensionSetting("elasticburp.host", self.confESHost) 77 | self.callbacks.saveExtensionSetting("elasticburp.index", self.confESIndex) 78 | self.callbacks.saveExtensionSetting("elasticburp.tools", str(self.confBurpTools)) 79 | self.callbacks.saveExtensionSetting("elasticburp.onlyresp", str(int(self.confBurpOnlyResp))) 80 | except Exception as e: 81 | JOptionPane.showMessageDialog(self.panel, "

Error while initializing ElasticSearch: %s

" % (str(e)), "Error", JOptionPane.ERROR_MESSAGE) 82 | 83 | ### ITab ### 84 | def getTabCaption(self): 85 | return "ElasticBurp" 86 | 87 | def applyConfigUI(self, event): 88 | #self.idx.close() 89 | self.confESHost = self.uiESHost.getText() 90 | self.confESIndex = self.uiESIndex.getText() 91 | self.confBurpTools = int((self.uiCBSuite.isSelected() and IBurpExtenderCallbacks.TOOL_SUITE) | (self.uiCBTarget.isSelected() and IBurpExtenderCallbacks.TOOL_TARGET) | (self.uiCBProxy.isSelected() and IBurpExtenderCallbacks.TOOL_PROXY) | (self.uiCBSpider.isSelected() and IBurpExtenderCallbacks.TOOL_SPIDER) | (self.uiCBScanner.isSelected() and IBurpExtenderCallbacks.TOOL_SCANNER) | (self.uiCBIntruder.isSelected() and IBurpExtenderCallbacks.TOOL_INTRUDER) | (self.uiCBRepeater.isSelected() and IBurpExtenderCallbacks.TOOL_REPEATER) | (self.uiCBSequencer.isSelected() and IBurpExtenderCallbacks.TOOL_SEQUENCER) | (self.uiCBExtender.isSelected() and IBurpExtenderCallbacks.TOOL_EXTENDER)) 92 | self.confBurpOnlyResp = self.uiCBOptRespOnly.isSelected() 93 | self.applyConfig() 94 | 95 | def resetConfigUI(self, event): 96 | self.uiESHost.setText(self.confESHost) 97 | self.uiESIndex.setText(self.confESIndex) 98 | self.uiCBSuite.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_SUITE)) 99 | self.uiCBTarget.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_TARGET)) 100 | self.uiCBProxy.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_PROXY)) 101 | self.uiCBSpider.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_SPIDER)) 102 | self.uiCBScanner.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_SCANNER)) 103 | self.uiCBIntruder.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_INTRUDER)) 104 | self.uiCBRepeater.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_REPEATER)) 105 | self.uiCBSequencer.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_SEQUENCER)) 106 | self.uiCBExtender.setSelected(bool(self.confBurpTools & IBurpExtenderCallbacks.TOOL_EXTENDER)) 107 | self.uiCBOptRespOnly.setSelected(self.confBurpOnlyResp) 108 | 109 | def getUiComponent(self): 110 | self.panel = JPanel() 111 | self.panel.setLayout(BoxLayout(self.panel, BoxLayout.PAGE_AXIS)) 112 | 113 | self.uiESHostLine = JPanel() 114 | self.uiESHostLine.setLayout(BoxLayout(self.uiESHostLine, BoxLayout.LINE_AXIS)) 115 | self.uiESHostLine.setAlignmentX(JPanel.LEFT_ALIGNMENT) 116 | self.uiESHostLine.add(JLabel("ElasticSearch Host: ")) 117 | self.uiESHost = JTextField(40) 118 | self.uiESHost.setMaximumSize(self.uiESHost.getPreferredSize()) 119 | self.uiESHostLine.add(self.uiESHost) 120 | self.panel.add(self.uiESHostLine) 121 | 122 | self.uiESIndexLine = JPanel() 123 | self.uiESIndexLine.setLayout(BoxLayout(self.uiESIndexLine, BoxLayout.LINE_AXIS)) 124 | self.uiESIndexLine.setAlignmentX(JPanel.LEFT_ALIGNMENT) 125 | self.uiESIndexLine.add(JLabel("ElasticSearch Index: ")) 126 | self.uiESIndex = JTextField(40) 127 | self.uiESIndex.setMaximumSize(self.uiESIndex.getPreferredSize()) 128 | self.uiESIndexLine.add(self.uiESIndex) 129 | self.panel.add(self.uiESIndexLine) 130 | 131 | uiToolsLine = JPanel() 132 | uiToolsLine.setLayout(BoxLayout(uiToolsLine, BoxLayout.LINE_AXIS)) 133 | uiToolsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT) 134 | self.uiCBSuite = JCheckBox("Suite") 135 | uiToolsLine.add(self.uiCBSuite) 136 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 137 | self.uiCBTarget = JCheckBox("Target") 138 | uiToolsLine.add(self.uiCBTarget) 139 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 140 | self.uiCBProxy = JCheckBox("Proxy") 141 | uiToolsLine.add(self.uiCBProxy) 142 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 143 | self.uiCBSpider = JCheckBox("Spider") 144 | uiToolsLine.add(self.uiCBSpider) 145 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 146 | self.uiCBScanner = JCheckBox("Scanner") 147 | uiToolsLine.add(self.uiCBScanner) 148 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 149 | self.uiCBIntruder = JCheckBox("Intruder") 150 | uiToolsLine.add(self.uiCBIntruder) 151 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 152 | self.uiCBRepeater = JCheckBox("Repeater") 153 | uiToolsLine.add(self.uiCBRepeater) 154 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 155 | self.uiCBSequencer = JCheckBox("Sequencer") 156 | uiToolsLine.add(self.uiCBSequencer) 157 | uiToolsLine.add(Box.createRigidArea(Dimension(10, 0))) 158 | self.uiCBExtender = JCheckBox("Extender") 159 | uiToolsLine.add(self.uiCBExtender) 160 | self.panel.add(uiToolsLine) 161 | self.panel.add(Box.createRigidArea(Dimension(0, 10))) 162 | 163 | uiOptionsLine = JPanel() 164 | uiOptionsLine.setLayout(BoxLayout(uiOptionsLine, BoxLayout.LINE_AXIS)) 165 | uiOptionsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT) 166 | self.uiCBOptRespOnly = JCheckBox("Process only responses (include requests)") 167 | uiOptionsLine.add(self.uiCBOptRespOnly) 168 | self.panel.add(uiOptionsLine) 169 | self.panel.add(Box.createRigidArea(Dimension(0, 10))) 170 | 171 | uiButtonsLine = JPanel() 172 | uiButtonsLine.setLayout(BoxLayout(uiButtonsLine, BoxLayout.LINE_AXIS)) 173 | uiButtonsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT) 174 | uiButtonsLine.add(JButton("Apply", actionPerformed=self.applyConfigUI)) 175 | uiButtonsLine.add(JButton("Reset", actionPerformed=self.resetConfigUI)) 176 | self.panel.add(uiButtonsLine) 177 | self.resetConfigUI(None) 178 | 179 | return self.panel 180 | 181 | ### IHttpListener ### 182 | def processHttpMessage(self, tool, isRequest, msg): 183 | if not tool & self.confBurpTools or isRequest and self.confBurpOnlyResp: 184 | return 185 | 186 | doc = self.genESDoc(msg) 187 | doc.save() 188 | 189 | ### IContextMenuFactory ### 190 | def createMenuItems(self, invocation): 191 | menuItems = list() 192 | selectedMsgs = invocation.getSelectedMessages() 193 | if selectedMsgs != None and len(selectedMsgs) >= 1: 194 | menuItems.append(JMenuItem("Add to ElasticSearch Index", actionPerformed=self.genAddToES(selectedMsgs, invocation.getInputEvent().getComponent()))) 195 | return menuItems 196 | 197 | def genAddToES(self, msgs, component): 198 | def menuAddToES(e): 199 | progress = ProgressMonitor(component, "Feeding ElasticSearch", "", 0, len(msgs)) 200 | i = 0 201 | docs = list() 202 | for msg in msgs: 203 | if not Burp_onlyResponses or msg.getResponse(): 204 | docs.append(self.genESDoc(msg, timeStampFromResponse=True).to_dict(True)) 205 | i += 1 206 | progress.setProgress(i) 207 | success, failed = bulk(self.es, docs, True, raise_on_error=False) 208 | progress.close() 209 | JOptionPane.showMessageDialog(self.panel, "

Successful imported %d messages, %d messages failed.

" % (success, failed), "Finished", JOptionPane.INFORMATION_MESSAGE) 210 | return menuAddToES 211 | 212 | ### Interface to ElasticSearch ### 213 | def genESDoc(self, msg, timeStampFromResponse=False): 214 | httpService = msg.getHttpService() 215 | doc = DocHTTPRequestResponse(protocol=httpService.getProtocol(), host=httpService.getHost(), port=httpService.getPort()) 216 | doc.meta.index = self.confESIndex 217 | 218 | request = msg.getRequest() 219 | response = msg.getResponse() 220 | 221 | if request: 222 | iRequest = self.helpers.analyzeRequest(msg) 223 | doc.request.method = iRequest.getMethod() 224 | doc.request.url = iRequest.getUrl().toString() 225 | 226 | headers = iRequest.getHeaders() 227 | for header in headers: 228 | try: 229 | doc.add_request_header(header) 230 | except: 231 | doc.request.requestline = header 232 | 233 | parameters = iRequest.getParameters() 234 | for parameter in parameters: 235 | ptype = parameter.getType() 236 | if ptype == IParameter.PARAM_URL: 237 | typename = "url" 238 | elif ptype == IParameter.PARAM_BODY: 239 | typename = "body" 240 | elif ptype == IParameter.PARAM_COOKIE: 241 | typename = "cookie" 242 | elif ptype == IParameter.PARAM_XML: 243 | typename = "xml" 244 | elif ptype == IParameter.PARAM_XML_ATTR: 245 | typename = "xmlattr" 246 | elif ptype == IParameter.PARAM_MULTIPART_ATTR: 247 | typename = "multipartattr" 248 | elif ptype == IParameter.PARAM_JSON: 249 | typename = "json" 250 | else: 251 | typename = "unknown" 252 | 253 | name = parameter.getName() 254 | value = parameter.getValue() 255 | doc.add_request_parameter(typename, name, value) 256 | 257 | ctype = iRequest.getContentType() 258 | if ctype == IRequestInfo.CONTENT_TYPE_NONE: 259 | doc.request.content_type = "none" 260 | elif ctype == IRequestInfo.CONTENT_TYPE_URL_ENCODED: 261 | doc.request.content_type = "urlencoded" 262 | elif ctype == IRequestInfo.CONTENT_TYPE_MULTIPART: 263 | doc.request.content_type = "multipart" 264 | elif ctype == IRequestInfo.CONTENT_TYPE_XML: 265 | doc.request.content_type = "xml" 266 | elif ctype == IRequestInfo.CONTENT_TYPE_JSON: 267 | doc.request.content_type = "json" 268 | elif ctype == IRequestInfo.CONTENT_TYPE_AMF: 269 | doc.request.content_type = "amf" 270 | else: 271 | doc.request.content_type = "unknown" 272 | 273 | bodyOffset = iRequest.getBodyOffset() 274 | doc.request.body = request[bodyOffset:].tostring().decode("ascii", "replace") 275 | 276 | if response: 277 | iResponse = self.helpers.analyzeResponse(response) 278 | 279 | doc.response.status = iResponse.getStatusCode() 280 | doc.response.content_type = iResponse.getStatedMimeType() 281 | doc.response.inferred_content_type = iResponse.getInferredMimeType() 282 | 283 | headers = iResponse.getHeaders() 284 | dateHeader = None 285 | for header in headers: 286 | try: 287 | doc.add_response_header(header) 288 | match = reDateHeader.match(header) 289 | if match: 290 | dateHeader = match.group(1) 291 | except: 292 | doc.response.responseline = header 293 | 294 | cookies = iResponse.getCookies() 295 | for cookie in cookies: 296 | expCookie = cookie.getExpiration() 297 | expiration = None 298 | if expCookie: 299 | try: 300 | expiration = str(datetime.fromtimestamp(expCookie.time / 1000)) 301 | except: 302 | pass 303 | doc.add_response_cookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(), expiration) 304 | 305 | bodyOffset = iResponse.getBodyOffset() 306 | doc.response.body = response[bodyOffset:].tostring().decode("ascii", "replace") 307 | 308 | if timeStampFromResponse: 309 | if dateHeader: 310 | try: 311 | doc.timestamp = datetime.fromtimestamp(mktime_tz(parsedate_tz(dateHeader)), tz) # try to use date from response header "Date" 312 | self.lastTimestamp = doc.timestamp 313 | except: 314 | doc.timestamp = self.lastTimestamp # fallback: last stored timestamp. Else: now 315 | 316 | return doc 317 | -------------------------------------------------------------------------------- /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 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 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 | {project} Copyright (C) {year} {fullname} 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WASE 2 | 3 | WASE is a shortcut for Web Audit Search Engine. It's a framework for indexing HTTP requests/responses while web 4 | application audits in an ElasticSearch instance and enriching it with useful data. The indexed data can then be searched 5 | and aggregated with ElasticSearch queries or with Kibana. 6 | 7 | Currently WASE contains the following parts: 8 | 9 | * doc\_HttpRequestResponse.py: a library that implements the DocHTTPRequestResponse class. This class is an 10 | elasticsearch\_dsl-based storage class of HTTP requests/responses (derived from Burps data structures and API). 11 | * ElasticBurp: a Burp plugin that feeds requests/responses into ElasticSearch. 12 | 13 | ## ElasticBurp 14 | 15 | Scared about the weak searching performance of Burp Suite? Are you missing possibilities to search in Burp? ElasticBurp 16 | combines Burp Suite with the search power of ElasticSearch. It can be installed directly from the [Burp BApp 17 | Store](https://portswigger.net/bappstore/ShowBappDetails.aspx?uuid=67f5c31f93d04ad3a3b0a1808b3648fa). 18 | 19 | 20 | ### Installation 21 | 22 | 1. Install ElasticSearch and Kibana. 23 | 2. Configure both - For security reasons it is recommend to let them listen on localhost: 24 | * Set `network.host: 127.0.0.1` in `/etc/elasticsearch/elasticsearch.yml`. 25 | * Set `host: "127.0.0.1"` in `/opt/kibana/config/kibana.yml`. 26 | 3. Install dependencies in the Jython environment used by Burp Extender with: `$JYTHON_PATH/bin/pip install -r 27 | requirements.txt` 28 | 4. Load ElasticBurp.py as Python extension in Burp Extender. 29 | 30 | Currently there seem to be incompatibilities with the new Python Elasticsearch packages. Specify the 2.2 version when installing 31 | with pip: `$JYTHON_HOME/bin/pip install elasticsearch_dsl==2.2` 32 | 33 | ### Usage 34 | 35 | See [this blog article](https://patzke.org/an-introduction-to-wase-and-elasticburp.html) for usage examples. 36 | 37 | ## WASEProxy 38 | 39 | A generic intercepting HTTP(S) proxy server that stores extracted data into an ElasticSearch index. 40 | 41 | Installation with pip: `pip install -r requirements-proxy.txt` 42 | 43 | ## WASEQuery 44 | 45 | Search ElasticSearch indices created by WASE for 46 | 47 | * responses with missing headers 48 | * responses with missing parameters 49 | * all values that were set for a header (e.g. X-Frame-Options, X-XSS-Protection, X-Content-Type-Options, Content-Security-Policy, ...) 50 | 51 | ...or do arbitrary search queries. 52 | 53 | Invoke WASEQuery.py for help message. [This blog 54 | article](https://patzke.org/analyzing-web-application-test-data-with-wasequery.html) shows some examples for usage of 55 | WASEQuery. 56 | -------------------------------------------------------------------------------- /WASEHTMLParser.py: -------------------------------------------------------------------------------- 1 | import sys 2 | if sys.version_info[0] == 2: 3 | from HTMLParser import HTMLParser 4 | else: 5 | from html.parser import HTMLParser 6 | 7 | # extract values from attrList of attributes whose name is contained in attrNames 8 | def add_attrs(attrNames, attrList): 9 | return [a[1] for a in filter(lambda attr: attr[0] in attrNames, attrList)] 10 | 11 | def has_attr(attrs, attr): 12 | return attr in map(lambda kv: kv[0], attrs) 13 | 14 | def attr_val_is(attrs, attr, val): 15 | try: 16 | return filter(lambda kv: kv[0] == attr, attrs)[0][1] == val 17 | except: 18 | return False 19 | 20 | class WASEHTMLParser(HTMLParser, object): 21 | def reset(self): 22 | self.doctype = set() 23 | self.base = set() 24 | self.stylesheets = set() 25 | self.frames = set() 26 | self.scripts = set() 27 | self.links = set() 28 | self.images = set() 29 | self.audio = set() 30 | self.video = set() 31 | self.objects = set() 32 | self.formactions = set() 33 | super(WASEHTMLParser, self).reset() 34 | 35 | def handle_decl(self, decl): 36 | self.doctype.add(decl) 37 | 38 | def handle_starttag(self, tag, attrs): 39 | if tag == "iframe": 40 | self.frames.update(add_attrs(["src"], attrs)) 41 | elif tag == "base": 42 | self.base.update(add_attrs(["href"], attrs)) 43 | elif tag == "link" and attr_val_is(attrs, "rel", "stylesheet"): 44 | self.stylesheets.update(add_attrs(["href"], attrs)) 45 | elif tag == "script": 46 | self.scripts.update(add_attrs(["src"], attrs)) 47 | elif tag == "a" or tag == "area": 48 | self.links.update(add_attrs(["href"], attrs)) 49 | elif tag == "img" or tag == "input": 50 | self.images.update(add_attrs(["src"], attrs)) 51 | elif tag == "svg" or tag == "image": 52 | self.images.update(add_attrs(["href", "xlink:href"], attrs)) 53 | elif tag == "audio": 54 | self.audio.update(add_attrs(["src"], attrs)) 55 | elif tag == "video": 56 | self.video.update(add_attrs(["src"], attrs)) 57 | elif tag == "object": 58 | self.objects.update(add_attrs(["data"], attrs)) 59 | elif tag == "embed": 60 | self.objects.update(add_attrs(["src"], attrs)) 61 | elif tag == "applet": 62 | self.objects.update(add_attrs(["code"], attrs)) 63 | elif tag == "form": 64 | self.formactions.update(add_attrs(["action"], attrs)) 65 | elif tag == "input" or tag == "button": 66 | self.formactions.update(add_attrs(["formaction"], attrs)) 67 | else: 68 | return 69 | 70 | def close(self): 71 | self.extrefs = set() 72 | self.extrefs.update( 73 | self.stylesheets, 74 | self.frames, 75 | self.scripts, 76 | self.links, 77 | self.images, 78 | self.audio, 79 | self.video, 80 | self.objects, 81 | self.formactions 82 | ) 83 | return super(WASEHTMLParser, self).close() 84 | -------------------------------------------------------------------------------- /WASEProxy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Intercepting Proxy that feeds HTTP(S) requests/responses into ElasticSearch based on pymiproxy and WASE 3 | 4 | from miproxy.proxy import ProxyHandler, MitmProxy, AsyncMitmProxy 5 | import argparse 6 | from httplib import HTTPResponse 7 | from Cookie import SimpleCookie 8 | from doc_HttpRequestResponse import DocHTTPRequestResponse 9 | from StringIO import StringIO 10 | from SocketServer import ForkingMixIn 11 | from BaseHTTPServer import BaseHTTPRequestHandler 12 | import re 13 | from elasticsearch_dsl.connections import connections 14 | from elasticsearch_dsl import Index 15 | 16 | args = None 17 | storeResponseBody = True 18 | reContentType = re.compile("^(.*?)(?:$|\s*;)") 19 | 20 | class ForkingAsyncMitmProxy(ForkingMixIn, MitmProxy): 21 | pass 22 | 23 | class WASEProxyHandler(ProxyHandler): 24 | """Intercepts HTTP(S) requests/responses, extracts data and feeds ElasticSearch""" 25 | def mitm_request(self, data): 26 | # Initialize ES connection and index 27 | res = connections.create_connection(hosts=[args.elasticsearch]) 28 | idx = Index(args.index) 29 | idx.doc_type(DocHTTPRequestResponse) 30 | try: 31 | DocHTTPRequestResponse.init() 32 | idx.create() 33 | except: 34 | pass 35 | 36 | r = HTTPRequest(data) 37 | 38 | # determine url 39 | if self.is_connect: 40 | scheme = "https" 41 | else: 42 | scheme = "http" 43 | url = scheme + "://" + self.hostname 44 | if scheme == "http" and int(self.port) != 80 or scheme == "https" and int(self.port) != 443: 45 | url += ":" + str(self.port) 46 | url += self.path 47 | 48 | if args.verbose: 49 | print(url) 50 | 51 | self.doc = DocHTTPRequestResponse(host=self.hostname, port=int(self.port), protocol=scheme) 52 | self.doc.meta.index = args.index 53 | self.doc.request.url = url 54 | self.doc.request.requestline = r.requestline 55 | self.doc.request.method = r.command 56 | self.doc.host = self.hostname 57 | self.doc.port = int(self.port) 58 | self.doc.protocol = scheme 59 | 60 | return data 61 | 62 | def mitm_response(self, data): 63 | lines = data.split("\r\n") 64 | r = HTTPResponse(FakeSocket(data)) 65 | r.begin() 66 | 67 | # response line 68 | self.doc.response.status = r.status 69 | self.doc.response.responseline = lines[0].decode(args.charset, args.encodingerrors) 70 | 71 | # headers 72 | ct = "" 73 | cookies = list() 74 | for header in r.getheaders(): 75 | name = header[0].decode(args.charset, args.encodingerrors) 76 | value = header[1].decode(args.charset, args.encodingerrors) 77 | self.doc.add_parsed_response_header(name, value) 78 | if name == "content-type": 79 | ct = value 80 | elif name == "set-cookie": 81 | cookies.append(value) 82 | 83 | # content type 84 | try: 85 | m = reContentType.search(ct) 86 | self.doc.response.content_type = m.group(1) 87 | except: 88 | pass 89 | 90 | # cookies 91 | for cookie in cookies: 92 | # TODO: the following code extracts only partial cookie data - check/rewrite 93 | try: 94 | pc = SimpleCookie(cookie) 95 | for name in pc.keys(): 96 | c = pc[name] 97 | try: 98 | value = c.value 99 | except AttributeError: 100 | value = None 101 | try: 102 | domain = c.domain 103 | except AttributeError: 104 | domain = None 105 | try: 106 | path = c.path 107 | except AttributeError: 108 | path = None 109 | try: 110 | exp = c.expires 111 | except AttributeError: 112 | exp = None 113 | self.doc.add_response_cookie(name, value, domain, path, exp) 114 | except: 115 | pass 116 | 117 | # body 118 | bodybytes = r.read() 119 | self.doc.response.body = bodybytes.decode(args.charset, args.encodingerrors) 120 | 121 | self.doc.save(storeResponseBody) 122 | return data 123 | 124 | # code copied from http://stackoverflow.com/questions/24728088/python-parse-http-response-string 125 | class FakeSocket(): 126 | def __init__(self, response_str): 127 | self._file = StringIO(response_str) 128 | 129 | def makefile(self, *args, **kwargs): 130 | return self._file 131 | 132 | # code copied from http://stackoverflow.com/questions/2115410/does-python-have-a-module-for-parsing-http-requests-and-responses 133 | class HTTPRequest(BaseHTTPRequestHandler): 134 | def __init__(self, request_text): 135 | self.rfile = StringIO(request_text) 136 | self.raw_requestline = self.rfile.readline() 137 | self.error_code = self.error_message = None 138 | self.parse_request() 139 | 140 | def send_error(self, code, message): 141 | self.error_code = code 142 | self.error_message = message 143 | 144 | ### Main ### 145 | argparser = argparse.ArgumentParser(description="Intercepting HTTP(S) proxy that forwards data into ElasticSearch WASE datastructure") 146 | argparser.add_argument("--listenaddr", "-l", default="localhost", help="IP/hostname the server binds to (default: %(default)s)") 147 | argparser.add_argument("--port", "-p", type=int, default=8080, help="Port the proxy server listens to (default: %(default)s)") 148 | argparser.add_argument("--elasticsearch", "-e", default="localhost", help="ElasticSearch instance (default: %(default)s)") 149 | argparser.add_argument("--index", "-i", default="wase-proxy", help="ElasticSearch index (default: %(default)s)") 150 | argparser.add_argument("--no-response-body", "-n", action="store_true", help="Don't store response body in ElasticSearch") 151 | argparser.add_argument("--charset", "-c", default="utf-8", help="Character set used for decoding of bytes responses into string passed to ES (default: %(default)s)") 152 | argparser.add_argument("--encodingerrors", "-E", default="ignore", choices=["ignore", "replace", "strict"], help="Behavior when encoding errors occur, must be ignore, replace or strict (default: %(default)s)") 153 | argparser.add_argument("--verbose", "-v", action="store_true", help="Be verbose") 154 | args = argparser.parse_args() 155 | 156 | if args.no_response_body: 157 | storeResponseBody = False 158 | 159 | # run proxy 160 | proxy = ForkingAsyncMitmProxy(RequestHandlerClass=WASEProxyHandler, server_address=(args.listenaddr, args.port)) 161 | try: 162 | proxy.serve_forever() 163 | except KeyboardInterrupt: 164 | proxy.server_close() 165 | -------------------------------------------------------------------------------- /WASEQuery.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import argparse 4 | from elasticsearch import Elasticsearch 5 | from elasticsearch_dsl import Search, Q, A 6 | from elasticsearch_dsl.query import Wildcard 7 | import sys 8 | 9 | ### Constants ### 10 | 11 | QUERY_SEARCH = 1 12 | QUERY_VALUES = 2 13 | 14 | ### Helpers ### 15 | 16 | def add_default_aggregation(s): 17 | a = A("terms", field="request.url.keyword", size=args.size) 18 | s.aggs.bucket("urls", a) 19 | 20 | def add_domain_filter(s): 21 | # add domain filters 22 | if args.domain: 23 | domain_filter = [] 24 | for domain in args.domain: 25 | domain_filter.append(Wildcard(** { "host": domain })) 26 | return s.filter("bool", should=domain_filter) 27 | else: 28 | return s 29 | 30 | def print_debug(*arglist): 31 | if args.debug: 32 | print(file=sys.stderr, *arglist) 33 | 34 | ### Query Subcommands ### 35 | 36 | def query_missing(s, field, name, methods=None, responsecodes=None, invert=False): 37 | # main query 38 | q = Q("match", ** { field: name }) 39 | if not invert: 40 | q = ~q 41 | s.query = q 42 | 43 | # add filters 44 | ## method 45 | if methods: 46 | s = s.filter("terms", ** { 'request.method': methods }) 47 | ## response codes 48 | if responsecodes: 49 | for rc in responsecodes: 50 | rcrange = rc.split("-") 51 | if len(rcrange) == 2: 52 | s = s.filter("range", ** { 'response.status': { "gte": int(rcrange[0]), "lte": int(rcrange[1]) } }) 53 | else: 54 | s = s.filter("term", ** { 'response.status': rc }) 55 | 56 | print_debug(s.to_dict()) 57 | return s 58 | 59 | def query_missingheader(s, headername, methods=None, responsecodes=None, invert=False): 60 | s = query_missing(s, 'response.headernames', headername, methods, responsecodes, invert) 61 | return s 62 | 63 | def query_missingparam(s, paramname, methods=None, responsecodes=None, invert=False): 64 | s = query_missing(s, 'request.parameternames', paramname, methods, responsecodes, invert) 65 | return s 66 | 67 | def query_vals(s, field, name, values, invert): 68 | # match documents where given field value name is present, if required 69 | if values: 70 | q = Q("nested", path=field, query=Q("wildcard", ** { field + ".value.keyword": values })) 71 | if invert: 72 | s.query = ~q 73 | else: 74 | s.query = q 75 | else: 76 | s.query = Q() 77 | 78 | # 1. descent into response.headers/request.parameters 79 | # 2. filter given header 80 | # 3. aggregate values 81 | # 4. jump back into main document 82 | # 5. aggregate URLs 83 | s.aggs.bucket("field", "nested", path=field)\ 84 | .bucket("valuefilter", "filter", Q("match", ** { field + ".name": name }))\ 85 | .bucket("values", "terms", field=field + ".value.keyword", size=args.size)\ 86 | .bucket("main", "reverse_nested")\ 87 | .bucket("urls", "terms", field="request.url.keyword", size=args.size) 88 | return s 89 | 90 | def query_responseheadervals(s, headername, values=None, invert=False): 91 | return query_vals(s, "response.headers", headername, values, invert) 92 | 93 | def query_requestheadervals(s, headername, values=None, invert=False): 94 | return query_vals(s, "request.headers", headername, values, invert) 95 | 96 | def query_parametervals(s, paramname, values=None, invert=False): 97 | return query_vals(s, "request.parameters", paramname, values, invert) 98 | 99 | def query_cookievals(s, cookiename, values=None, invert=False): 100 | return query_vals(s, "response.cookies", cookiename, values, invert) 101 | 102 | def query(s, q): 103 | s.query = Q("query_string", query=q) 104 | return s 105 | 106 | ### Main ### 107 | argparser = argparse.ArgumentParser(description="WASE Query Tool") 108 | argparser.add_argument("--server", "-s", default="localhost", help="ElasticSearch server") 109 | argparser.add_argument("--index", "-i", default="wase-*", help="ElasticSearch index pattern to query") 110 | argparser.add_argument("--size", "-S", default=10000, type=int, help="Maximum number of results of aggregation (default: %(default)s)") 111 | argparser.add_argument("--field", "-f", action="append", help="Add fields to output. Prints full result instead of aggregated URLs.") 112 | argparser.add_argument("--domain", "-d", action="append", help="Restrict search to domain. Wildcards allowed. Can be used multiple times.") 113 | argparser.add_argument("--debug", "-D", action="store_true", help="Debugging output") 114 | subargparsers = argparser.add_subparsers(title="Query Commands", dest="cmd") 115 | 116 | argparser_missingheader = subargparsers.add_parser("missingheader", help="Search for URLs which responses are missing a header") 117 | argparser_missingheader.add_argument("header", help="Name of the header") 118 | argparser_missingheader.add_argument("--invert", "-i", action="store_true", help="Invert result, list all URLs where header is set") 119 | argparser_missingheader.add_argument("--method", "-m", action="append", help="Restrict search to given methods") 120 | argparser_missingheader.add_argument("--responsecode", "-c", action="append", help="Restrict search to responses with the given codes. Can be a single code (e.g. 200), a range (200-299) or wildcard (2*)") 121 | 122 | argparser_missingparam = subargparsers.add_parser("missingparameter", help="Search for URLs where the requests are missing a parameter with the given name") 123 | argparser_missingparam.add_argument("parameter", help="Name of parameter to search") 124 | argparser_missingparam.add_argument("--invert", "-i", action="store_true", help="Invert result, list all URLs where header is set") 125 | argparser_missingparam.add_argument("--method", "-m", action="append", help="Restrict search to given methods") 126 | argparser_missingparam.add_argument("--responsecode", "-c", action="append", help="Restrict search to responses with the given codes. Can be a single code (e.g. 200), a range (200-299) or wildcard (2*)") 127 | #argparser_missingparam.add_argument("--type", "-t", choices=["url", "body", "cookie", "xml", "xmlattr", "multipartattr", "json", "unknown"], help="Restrict search to given request parameter type") 128 | 129 | argparser_responseheadervals = subargparsers.add_parser("responseheadervalues", help="Show all response header values and the URLs where the value was set") 130 | argparser_responseheadervals.add_argument("--urls", "-u", action="store_true", help="List URLs where header value is set") 131 | argparser_responseheadervals.add_argument("--max-urls", "-n", type=int, default=0, help="Maximum number of listed URLs") 132 | argparser_responseheadervals.add_argument("--values", "-v", help="Restrict to values matching the given pattern (wildcards allowed)") 133 | argparser_responseheadervals.add_argument("--invert", "-i", action="store_true", help="Invert values search") 134 | argparser_responseheadervals.add_argument("header", help="Name of the response header") 135 | 136 | argparser_requestheadervals = subargparsers.add_parser("requestheadervalues", help="Show all request header values and the URLs where the value was set") 137 | argparser_requestheadervals.add_argument("--urls", "-u", action="store_true", help="List URLs where header value is set") 138 | argparser_requestheadervals.add_argument("--max-urls", "-n", type=int, default=0, help="Maximum number of listed URLs") 139 | argparser_requestheadervals.add_argument("--values", "-v", help="Restrict to values matching the given pattern (wildcards allowed)") 140 | argparser_requestheadervals.add_argument("--invert", "-i", action="store_true", help="Invert values search") 141 | argparser_requestheadervals.add_argument("header", help="Name of the response header") 142 | 143 | argparser_cookievals = subargparsers.add_parser("cookievalues", help="Show all cookie values and the URLs where the value was set") 144 | argparser_cookievals.add_argument("--urls", "-u", action="store_true", help="List URLs where header value is set") 145 | argparser_cookievals.add_argument("--max-urls", "-n", type=int, default=0, help="Maximum number of listed URLs") 146 | argparser_cookievals.add_argument("--values", "-v", help="Restrict to values matching the given pattern (wildcards allowed)") 147 | argparser_cookievals.add_argument("--invert", "-i", action="store_true", help="Invert values search") 148 | argparser_cookievals.add_argument("cookie", help="Name of the cookie") 149 | 150 | argparser_paramvals = subargparsers.add_parser("parametervalues", help="Show all request parameter values and the URLs where the value was set") 151 | argparser_paramvals.add_argument("--urls", "-u", action="store_true", help="List URLs where parameter value is set") 152 | argparser_paramvals.add_argument("--max-urls", "-n", type=int, default=0, help="Maximum number of listed URLs") 153 | argparser_paramvals.add_argument("--values", "-v", help="Restrict to values matching the given pattern (wildcards allowed)") 154 | argparser_paramvals.add_argument("--invert", "-i", action="store_true", help="Invert values search") 155 | argparser_paramvals.add_argument("parameter", help="Name of the request parameter") 156 | 157 | argparser_search = subargparsers.add_parser("search", help="Make arbitrary queries") 158 | argparser_search.add_argument("query", nargs="*", default=["*"], help="Query string") 159 | 160 | args = argparser.parse_args() 161 | print_debug(args) 162 | 163 | es = Elasticsearch(args.server) 164 | s = Search(using=es).index(args.index) 165 | r = None 166 | 167 | querytype = None 168 | if args.cmd == "missingheader": 169 | s = query_missingheader(s, args.header, args.method, args.responsecode, args.invert) 170 | querytype = QUERY_SEARCH 171 | elif args.cmd == "missingparameter": 172 | s = query_missingparam(s, args.parameter, args.method, args.responsecode, args.invert) 173 | querytype = QUERY_SEARCH 174 | elif args.cmd == "responseheadervalues": 175 | s = query_responseheadervals(s, args.header, args.values, args.invert) 176 | querytype = QUERY_VALUES 177 | elif args.cmd == "requestheadervalues": 178 | s = query_requestheadervals(s, args.header, args.values, args.invert) 179 | querytype = QUERY_VALUES 180 | elif args.cmd == "cookievalues": 181 | s = query_cookievals(s, args.cookie, args.values, args.invert) 182 | querytype = QUERY_VALUES 183 | elif args.cmd == "parametervalues": 184 | s = query_parametervals(s, args.parameter, args.values, args.invert) 185 | querytype = QUERY_VALUES 186 | elif args.cmd == "search": 187 | s = query(s, " ".join(args.query)) 188 | querytype = QUERY_SEARCH 189 | else: 190 | argparser.print_help() 191 | sys.exit(1) 192 | 193 | s = add_domain_filter(s) 194 | 195 | if querytype == QUERY_SEARCH: 196 | if args.field: 197 | print_debug(s.to_dict()) 198 | r = s.scan() 199 | else: 200 | add_default_aggregation(s) 201 | print_debug(s.to_dict()) 202 | r = s.execute() 203 | 204 | if not r: 205 | print("No matches!") 206 | sys.exit(0) 207 | if args.field: 208 | for d in r: 209 | print(d['request']['url']) 210 | for f in args.field: 211 | print(f, end=": ") 212 | fl = f.split(".", 1) 213 | try: 214 | if len(fl) == 2: 215 | print(d[fl[0]][fl[1]]) 216 | else: 217 | print(d[f]) 218 | except KeyError: 219 | print("-") 220 | print() 221 | else: 222 | for d in r.aggregations.urls.buckets: 223 | print(d['key']) 224 | elif querytype == QUERY_VALUES: 225 | print_debug(s.to_dict()) 226 | r = s.execute() 227 | 228 | for hv in r.aggregations.field.valuefilter.values.buckets: 229 | print(hv.key) 230 | if args.urls: 231 | urlcnt = -1 232 | if args.max_urls > 0: 233 | urlcnt = args.max_urls 234 | 235 | for url in hv.main.urls.buckets: 236 | print(url.key) 237 | if urlcnt >= 0: 238 | urlcnt -= 1 239 | if urlcnt == 0: 240 | break 241 | print() 242 | -------------------------------------------------------------------------------- /doc_HttpRequestResponse.py: -------------------------------------------------------------------------------- 1 | # WASE - Web Audit Search Engine 2 | # doc_HttpRequestResponse.py: Implementation of the core data structure 3 | # 4 | # Copyright 2016 Thomas Patzke 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | from elasticsearch_dsl import DocType, Text, Keyword, Integer, Short, Date, Object, Nested, MetaField, analyzer 20 | from datetime import datetime 21 | import re 22 | from WASEHTMLParser import WASEHTMLParser 23 | from tzlocal import get_localzone 24 | 25 | reHeader = re.compile("^(.*?):\s*(.*)$") 26 | try: 27 | tz = get_localzone() 28 | except: 29 | tz = None 30 | 31 | def parse_header(header): 32 | # TODO: support for multiline headers 33 | match = reHeader.search(header) 34 | if match: 35 | return { 'name': match.group(1), 'value': match.group(2) } 36 | else: 37 | raise ValueError("No header matched") 38 | 39 | identifierAnalyzer = analyzer("identifier", 40 | tokenizer = "keyword", 41 | filter = ["lowercase"] 42 | ) 43 | 44 | class DocHTTPRequestResponse(DocType): 45 | timestamp = Date() 46 | protocol = Keyword() 47 | host = Keyword() 48 | port = Integer() 49 | request = Object( 50 | properties = { 51 | 'method': Keyword(), 52 | 'url': Text(fields={'keyword': Keyword()}), 53 | 'requestline': Text(fields={'keyword': Keyword()}), 54 | 'content_type': Text(fields={'keyword': Keyword()}), 55 | 'headernames': Text(analyzer=identifierAnalyzer, multi=True, fields={'keyword': Keyword()}), 56 | 'headers': Nested( 57 | properties = { 58 | 'name': Text(analyzer=identifierAnalyzer, fields={'keyword': Keyword()}), 59 | 'value': Text(fields={'keyword': Keyword()}) 60 | } 61 | ), 62 | 'parameternames': Text(analyzer=identifierAnalyzer, multi=True, fields={'keyword': Keyword()}), 63 | 'parameters': Nested( 64 | properties = { 65 | 'type': Keyword(), 66 | 'name': Text(analyzer=identifierAnalyzer, fields={'keyword': Keyword()}), 67 | 'value': Text(fields={'keyword': Keyword()}) 68 | } 69 | ), 70 | 'body': Text() 71 | } 72 | ) 73 | response = Object( 74 | properties = { 75 | 'status': Short(), 76 | 'responseline': Text(fields={'keyword': Keyword()}), 77 | 'content_type': Text(fields={'keyword': Keyword()}), 78 | 'inferred_content_type': Text(fields={'keyword': Keyword()}), 79 | 'headernames': Text(analyzer=identifierAnalyzer, multi=True, fields={'keyword': Keyword()}), 80 | 'headers': Nested( 81 | properties = { 82 | 'name': Text(analyzer=identifierAnalyzer, fields={'keyword': Keyword()}), 83 | 'value': Text(fields={'keyword': Keyword()}) 84 | } 85 | ), 86 | 'cookienames': Text(analyzer=identifierAnalyzer, multi=True, fields={'keyword': Keyword()}), 87 | 'cookies': Nested( 88 | properties = { 89 | 'domain': Text(fields={'keyword': Keyword()}), 90 | 'expiration': Date(fields={'keyword': Keyword()}), 91 | 'name': Text(analyzer=identifierAnalyzer, fields={'keyword': Keyword()}), 92 | 'path': Text(fields={'keyword': Keyword()}), 93 | 'value': Text(fields={'keyword': Keyword()}) 94 | } 95 | ), 96 | 'body': Text(), 97 | 'doctype': Text(multi=True, fields={'keyword': Keyword()}), 98 | 'base': Text(multi=True, fields={'keyword': Keyword()}), 99 | 'stylesheets': Text(multi=True, fields={'keyword': Keyword()}), 100 | 'frames': Text(multi=True, fields={'keyword': Keyword()}), 101 | 'scripts': Text(multi=True, fields={'keyword': Keyword()}), 102 | 'links': Text(multi=True, fields={'keyword': Keyword()}), 103 | 'images': Text(multi=True, fields={'keyword': Keyword()}), 104 | 'audio': Text(multi=True, fields={'keyword': Keyword()}), 105 | 'video': Text(multi=True, fields={'keyword': Keyword()}), 106 | 'objects': Text(multi=True, fields={'keyword': Keyword()}), 107 | 'formactions': Text(multi=True, fields={'keyword': Keyword()}), 108 | 'extrefs': Text(multi=True, fields={'keyword': Keyword()}), # all external references 109 | } 110 | ) 111 | 112 | def add_request_header(self, header): 113 | parsed = parse_header(header) 114 | self.request.headers.append(parsed) 115 | self.request.headernames.append(parsed['name']) 116 | 117 | def add_response_header(self, header): 118 | parsed = parse_header(header) 119 | self.response.headers.append(parsed) 120 | self.response.headernames.append(parsed['name']) 121 | 122 | def add_parsed_request_header(self, name, value): 123 | self.request.headers.append({"name": name, "value": value}) 124 | self.request.headernames.append(name) 125 | 126 | def add_parsed_response_header(self, name, value): 127 | self.response.headers.append({"name": name, "value": value}) 128 | self.response.headernames.append(name) 129 | 130 | def add_request_parameter(self, typename, name, value): 131 | param = { 'type': typename, 'name': name, 'value': value } 132 | self.request.parameters.append(param) 133 | self.request.parameternames.append(param['name']) 134 | 135 | def add_response_cookie(self, name, value, domain=None, path=None, expiration=None): 136 | cookie = { 'name': name, 'value': value, 'domain': domain, 'path': path, 'expiration': expiration } 137 | self.response.cookies.append(cookie) 138 | self.response.cookienames.append(cookie['name']) 139 | 140 | def save(self, storeResponseBody=True, **kwargs): 141 | if not self.timestamp: 142 | self.timestamp = datetime.now(tz) # TODO: timestamp options: now (as is), request and response 143 | if self.response.body and ((self.response.inferred_content_type and self.response.inferred_content_type == "HTML") or (not self.response.inferred_content_type and "HTML" in self.response.content_type or "html" in self.response.content_type)): 144 | parser = WASEHTMLParser() 145 | parser.feed(self.response.body) 146 | parser.close() 147 | 148 | self.response.doctype = list(parser.doctype) 149 | self.response.base = list(parser.base) 150 | self.response.stylesheets = list(parser.stylesheets) 151 | self.response.frames = list(parser.frames) 152 | self.response.scripts = list(parser.scripts) 153 | self.response.links = list(parser.links) 154 | self.response.images = list(parser.images) 155 | self.response.audio = list(parser.audio) 156 | self.response.video = list(parser.video) 157 | self.response.objects = list(parser.objects) 158 | self.response.formactions = list(parser.formactions) 159 | self.response.extrefs = list(parser.extrefs) 160 | 161 | if not storeResponseBody: 162 | self.response.body = None 163 | return super(DocHTTPRequestResponse, self).save(**kwargs) 164 | -------------------------------------------------------------------------------- /queries.txt: -------------------------------------------------------------------------------- 1 | Simple 2 | ====== 3 | All responses that set cookies: 4 | response.headernames:"Set-Cookie" 5 | 6 | All responses without X-Frame-Options header: 7 | NOT response.headernames:"X-Frame-Options" 8 | 9 | All detected HTML responses: 10 | response.inferred_content_type:html 11 | 12 | Detected and declared HTML responses: 13 | response.inferred_content_type:html OR response.content_type:html 14 | 15 | All request with a particular parameter: 16 | request.parameternames:csrftoken 17 | 18 | All request without a particular parameter: 19 | NOT request.parameternames:csrftoken 20 | 21 | ...only POST requests: 22 | request.method:POST -request.parameternames.raw:"csrftoken" 23 | 24 | All responses without a doctype definition: 25 | response.inferred_content_type:html -doctype 26 | 27 | ...and only 200 responses: 28 | response.status:200 AND response.inferred_content_type:html -doctype 29 | 30 | All responses that were recognized as HTML but declared as something different: 31 | response.inferred_content_type:html -response.content_type:html 32 | 33 | JSON 34 | ==== 35 | 36 | All requests with HEADERNAME header: 37 | { 38 | "query": { 39 | "nested": { 40 | "path": "response.headers", 41 | "query": { 42 | "match_phrase": { 43 | "response.headers.name": "HEADERNAME" 44 | } 45 | } 46 | } 47 | } 48 | } 49 | 50 | All requests without HEADERNAME header: 51 | { 52 | "query": { 53 | "bool": { 54 | "must_not": { 55 | "nested": { 56 | "path": "response.headers", 57 | "query": { 58 | "match_phrase": { 59 | "response.headers.name": "HEADERNAME" 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } 67 | 68 | All requests with HEADERNAME header with value VALUE: 69 | { 70 | "query": { 71 | "nested": { 72 | "path": "response.headers", 73 | "query": { 74 | "bool": { 75 | "must_not": { 76 | "match_phrase": { 77 | "response.headers.name": "X-Frame-Options" 78 | }, 79 | "match_phrase": { 80 | "response.headers.value": "SAMEORIGIN" 81 | } 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | 89 | All requests without HEADERNAME header with value VALUE: 90 | { 91 | "query": { 92 | "bool": { 93 | "must_not": { 94 | "nested": { 95 | "path": "response.headers", 96 | "query": { 97 | "match_phrase": { 98 | "response.headers.name": "HEADERNAME", 99 | "response.headers.value": "VALUE" 100 | } 101 | } 102 | } 103 | } 104 | } 105 | } 106 | } 107 | 108 | All POST requests: 109 | { 110 | "query": { 111 | "match_phrase": { 112 | "request.method": "POST" 113 | } 114 | } 115 | } 116 | 117 | All POST requests without parameter PARAMNAME: 118 | { 119 | "query": { 120 | "bool": { 121 | "must": { 122 | "match_phrase": { 123 | "request.method": "POST" 124 | } 125 | }, 126 | "must_not": { 127 | "nested": { 128 | "path": "request.parameters", 129 | "query": { 130 | "match_phrase": { 131 | "request.parameters.name": "PARAMNAME" 132 | } 133 | } 134 | } 135 | } 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /requirements-proxy.txt: -------------------------------------------------------------------------------- 1 | cryptography==1.8.1 2 | elasticsearch==5.1.0 3 | elasticsearch-dsl==5.1.0 4 | pymiproxy==1.0 5 | pyparsing==2.2.0 6 | six==1.10.0 7 | tzlocal==1.3 8 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | elasticsearch==6.0.0 2 | elasticsearch-dsl==6.0.0 3 | tzlocal==1.3 4 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | from doc_HttpRequestResponse import DocHTTPRequestResponse 2 | from elasticsearch_dsl.connections import connections 3 | from elasticsearch_dsl import Index 4 | from datetime import datetime 5 | 6 | connections.create_connection(hosts=["localhost"]) 7 | 8 | idx = Index("test") 9 | idx.doc_type(DocHTTPRequestResponse) 10 | #idx.create() 11 | 12 | DocHTTPRequestResponse.init() 13 | 14 | d = DocHTTPRequestResponse( 15 | protocol="http", 16 | host="foobar.com", 17 | port=80 18 | ) 19 | d.add_request_header("User-Agent: foobar") 20 | d.add_request_parameter("url", "id", "123") 21 | d.add_request_parameter("url", "doc", "234") 22 | d.add_response_header("X-Content-Type-Options: nosniff") 23 | d.add_response_header("X-Frame-Options: DENY") 24 | d.add_response_header("X-XSS-Protection: 1; mode=block") 25 | d.add_response_cookie("SESSIONID", "foobar1234") 26 | d.add_response_cookie("foo", "bar", "foobar.com", "/foo", datetime.now()) 27 | d.response.body = "This is a test!" 28 | d.request.method = "GET" 29 | d.save() 30 | 31 | d = DocHTTPRequestResponse( 32 | protocol="http", 33 | host="foobar.com", 34 | port=80 35 | ) 36 | d.add_request_header("User-Agent: foobar") 37 | d.add_request_parameter("url", "id", "123") 38 | d.add_request_parameter("url", "doc", "456") 39 | d.add_response_header("X-Frame-Options: SAMEORIGIN") 40 | d.add_response_cookie("SESSIONID", "foobar1234") 41 | d.add_response_cookie("foo", "bar", "foobar.com", "/foo", datetime.now()) 42 | d.request.method = "GET" 43 | d.response.body = "This is a test!" 44 | d.save() 45 | 46 | d = DocHTTPRequestResponse( 47 | protocol="http", 48 | host="foobar.com", 49 | port=80 50 | ) 51 | d.add_request_header("User-Agent: foobar") 52 | d.add_request_parameter("body", "action", "add") 53 | d.add_request_parameter("body", "doc", "456") 54 | d.add_request_parameter("body", "content", "Test") 55 | d.add_request_parameter("body", "csrftoken", "trulyrandom") 56 | d.add_response_header("X-Frame-Options: SAMEORIGIN") 57 | d.add_response_cookie("SESSIONID", "foobar1234") 58 | d.add_response_cookie("foo", "bar", "foobar.com", "/foo", datetime.now()) 59 | d.request.method = "POST" 60 | d.response.body = "Added!" 61 | d.save() 62 | 63 | d = DocHTTPRequestResponse( 64 | protocol="http", 65 | host="foobar.com", 66 | port=80 67 | ) 68 | d.add_request_header("User-Agent: foobar") 69 | d.add_request_parameter("body", "action", "delete") 70 | d.add_request_parameter("body", "doc", "456") 71 | d.add_response_header("X-Frame-Options: SAMEORIGIN") 72 | d.add_response_cookie("SESSIONID", "foobar1234") 73 | d.add_response_cookie("foo", "bar", "foobar.com", "/foo", datetime.now()) 74 | d.request.method = "POST" 75 | d.response.body = "Deleted!" 76 | d.save() 77 | -------------------------------------------------------------------------------- /waseproxy.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=WASE Proxy 3 | After=network.target 4 | 5 | [Service] 6 | EnvironmentFile=/etc/default/wase 7 | ExecStart=/opt/WASE/WASEProxy.py -e ${ES_HOST}:80 -i ${ES_INDEX} ${PARAMS} 8 | WorkingDirectory=/opt/WASE 9 | User=wase 10 | Restart=always 11 | RestartSec=10 12 | 13 | [Install] 14 | WantedBy=multi-user.target 15 | --------------------------------------------------------------------------------