1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
| ''' Author: gh0stNinja Blog: https://gh0stninja.github.io/ Date: 2024-06-14 14:31:34 Description: ''' from burp import IBurpExtender, IHttpListener, ITab, IExtensionHelpers from javax.swing import JPanel, JLabel, JTextField, JButton, JCheckBox, JTextArea, JScrollPane, JRadioButton, ButtonGroup, BoxLayout, Box from javax.swing.border import EmptyBorder from java.awt import BorderLayout import java.net.URL import random import sys import json
reload(sys) sys.setdefaultencoding('utf8')
class BurpExtender(IBurpExtender, IHttpListener, ITab): def registerExtenderCallbacks(self, callbacks): self._callbacks = callbacks self._helpers = callbacks.getHelpers() self._callbacks.setExtensionName("Proxy Switcher") self._callbacks.registerHttpListener(self) self.panel = JPanel() self.panel.setLayout(BorderLayout()) self.top_panel = JPanel() self.toggle_plugin = JCheckBox(u"开启插件", actionPerformed=self.toggleSwitch) self.clear_button = JButton(u'清除日志', actionPerformed=self.clearOutput) self.load_from_text_button = JButton(u'加载代理', actionPerformed=self.loadProxiesFromText)
self.http_address_label = JLabel(u"URL地址: ") self.http_address_field = JTextField("http://192.168.1.204:5010/all/", 20) self.fetch_proxies_button = JButton(u'获取代理', actionPerformed=self.fetchProxies)
self.radio_http = JRadioButton("HTTP", True) self.radio_https = JRadioButton("HTTPS") self.radio_group = ButtonGroup() self.radio_group.add(self.radio_http) self.radio_group.add(self.radio_https) self.top_panel.add(self.toggle_plugin) self.top_panel.add(Box.createHorizontalStrut(20)) self.top_panel.add(self.http_address_label) self.top_panel.add(self.http_address_field) self.top_panel.add(self.fetch_proxies_button) self.top_panel.add(self.load_from_text_button) self.top_panel.add(self.clear_button) self.top_panel.add(Box.createHorizontalStrut(20)) self.top_panel.add(Box.createHorizontalStrut(20)) self.top_panel.add(self.radio_http) self.top_panel.add(self.radio_https) self.middle_panel = JPanel() self.middle_panel.setLayout(BoxLayout(self.middle_panel, BoxLayout.X_AXIS)) self.proxy_panel = JPanel() self.proxy_panel.setLayout(BorderLayout()) self.proxy_label = JLabel(u" Proxy Lists") self.proxy_text_area = JTextArea(10, 30) self.proxy_scroll_pane = JScrollPane(self.proxy_text_area) self.proxy_panel.add(self.proxy_label, BorderLayout.NORTH) self.proxy_panel.add(self.proxy_scroll_pane, BorderLayout.CENTER) separator_panel = JPanel() separator_panel.setBorder(EmptyBorder(0, 1, 0, 1)) self.log_panel = JPanel() self.log_panel.setLayout(BorderLayout()) self.log_label = JLabel(u" Logs") self.response_area = JTextArea(10, 30) self.response_area.setEditable(False) self.scroll_pane = JScrollPane(self.response_area) self.log_panel.add(self.log_label, BorderLayout.NORTH) self.log_panel.add(self.scroll_pane, BorderLayout.CENTER) self.middle_panel.add(self.proxy_panel) self.middle_panel.add(separator_panel) self.middle_panel.add(self.log_panel) self.panel.add(self.top_panel, BorderLayout.NORTH) self.panel.add(self.middle_panel, BorderLayout.CENTER) self.enabled = False self.proxies = [] self._callbacks.addSuiteTab(self) print(u"Proxy Switcher loaded.") print(u"作者: gh0stNinja") print(u"GitHub: https://github.com/gh0stNinja") print(u"Blog: https://gh0stninja.github.io/")
def getTabCaption(self): return u"Proxy Switcher"
def getUiComponent(self): return self.panel
def toggleSwitch(self, event): self.enabled = self.toggle_plugin.isSelected() if self.enabled: self.response_area.append(u"插件已启用\n") else: self.response_area.append(u"插件已关闭\n")
def fetchProxies(self, event): if not self.enabled: return url = self.http_address_field.getText() if not url: self.response_area.append(u"请输入有效的HTTP地址。\n") return try: req = java.net.URL(url) connection = req.openConnection() connection.setRequestMethod("GET") connection.connect() inputStream = connection.getInputStream() response = self._helpers.bytesToString(inputStream.readAllBytes()) proxies = json.loads(response) self.displayProxies(proxies) except Exception as e: self.response_area.append(u"获取代理时出错: {}\n".format(str(e)))
def displayProxies(self, proxies): self.proxy_text_area.setText("") for proxy in proxies: if self.radio_https.isSelected(): if proxy['https']: proxy_address = proxy.get('proxy', '') self.proxy_text_area.append("[HTTPS] {}\n".format(proxy_address)) else: if not proxy['https']: proxy_address = proxy.get('proxy', '') self.proxy_text_area.append("[HTTP] {}\n".format(proxy_address)) self.response_area.append(u"代理获取成功\n") proxy_text = self.proxy_text_area.getText() self.proxies = [line.strip() for line in proxy_text.split('\n') if line.strip()] self.response_area.append(u"Proxy List loaded.\n")
def loadProxiesFromText(self, event=None): if not self.enabled: return self.proxies = [] proxy_text = self.proxy_text_area.getText() self.proxies = [line.strip() for line in proxy_text.split('\n') if line.strip()] self.response_area.append(u"Proxy List loaded.\n")
def clearOutput(self, event): self.response_area.setText("")
def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): if not self.enabled or not messageIsRequest: return if toolFlag in (self._callbacks.TOOL_INTRUDER, self._callbacks.TOOL_REPEATER) and self.proxies: proxy = random.choice(self.proxies) proxy = proxy.split(" ")[1] host, port = proxy.split(":") protocol = "http" messageInfo.setHttpService(self._helpers.buildHttpService(host, int(port), protocol)) self.response_area.append("[ {} ] [ {} ] [ {}:{} ]\n".format(self._callbacks.getToolName(toolFlag), protocol.upper(), host, port))
def main(): return BurpExtender()
if __name__ == "__main__": main()
|