├── BurpSuiteMagickByteSelector.gif ├── MagicByteSelector.py └── README.md /BurpSuiteMagickByteSelector.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/websecnl/MagicByteSelector/56903b9bc5abf9fddd03f310ccf100b1f34d7158/BurpSuiteMagickByteSelector.gif -------------------------------------------------------------------------------- /MagicByteSelector.py: -------------------------------------------------------------------------------- 1 | ##################### 2 | # WebSec BV # 3 | # Joel Aviad Ossi # 4 | # https://websec.nl # 5 | ##################### 6 | from burp import IBurpExtender, IContextMenuFactory, IContextMenuInvocation 7 | from javax.swing import JMenuItem 8 | from java.util import ArrayList 9 | 10 | class BurpExtender(IBurpExtender, IContextMenuFactory): 11 | def registerExtenderCallbacks(self, callbacks): 12 | self._callbacks = callbacks 13 | self._helpers = callbacks.getHelpers() 14 | callbacks.setExtensionName("Magic Byte Selector") 15 | callbacks.registerContextMenuFactory(self) 16 | 17 | print("This extension is made by https://websec.nl Research & Development Team,\n" 18 | "If you like this tool then please consider leaving us a positive google review\n" 19 | "and/or star our projects on GitHub. Happy hacking!") 20 | 21 | def createMenuItems(self, invocation): 22 | self._invocation = invocation 23 | 24 | # Check if the editor is writable 25 | context = self._invocation.getInvocationContext() 26 | if context not in [IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST, 27 | IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_RESPONSE]: 28 | return None 29 | 30 | menuList = ArrayList() 31 | menuList.add(JMenuItem("Insert JPG Magic Byte", actionPerformed=lambda x: self.insertMagicBytes('JPG'))) 32 | menuList.add(JMenuItem("Insert PNG Magic Byte", actionPerformed=lambda x: self.insertMagicBytes('PNG'))) 33 | menuList.add(JMenuItem("Insert JPEG Magic Byte", actionPerformed=lambda x: self.insertMagicBytes('JPEG'))) 34 | menuList.add(JMenuItem("Insert GIF89a Magic Byte", actionPerformed=lambda x: self.insertMagicBytes('GIF89a'))) 35 | menuList.add(JMenuItem("Insert GIF87a Magic Byte", actionPerformed=lambda x: self.insertMagicBytes('GIF87a'))) 36 | return menuList 37 | 38 | def insertMagicBytes(self, file_type): 39 | try: 40 | magic_bytes = { 41 | 'JPG': b"\xFF\xD8\xFF", 42 | 'PNG': b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 43 | 'JPEG': b"\xFF\xD8\xFF\xE0", 44 | 'GIF89a': b"\x47\x49\x46\x38\x39\x61", 45 | 'GIF87a': b"\x47\x49\x46\x38\x37\x61", 46 | } 47 | 48 | # Get the selected data boundaries 49 | selection_bounds = self._invocation.getSelectionBounds() 50 | 51 | # Get the HTTP request and selected data 52 | byte_request = bytearray(self._invocation.getSelectedMessages()[0].getRequest()) 53 | 54 | # Print the selection bounds and selected data for debugging 55 | print("Selection bounds: {}\nSelected data: {}".format(selection_bounds, byte_request[selection_bounds[0]:selection_bounds[1]])) 56 | 57 | # Insert the magic bytes at the correct position 58 | new_request = byte_request[:selection_bounds[0]] + magic_bytes[file_type] + byte_request[selection_bounds[0]:] 59 | 60 | # Update the HTTP request 61 | self._invocation.getSelectedMessages()[0].setRequest(bytes(new_request)) 62 | except Exception as e: 63 | print("An error occurred while inserting magic bytes: {}".format(str(e))) 64 | 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MagicByteSelector 2 | Burp Suite Extension for inserting a magic byte into responder's request 3 | 4 | # Preview 5 | 6 | ![](BurpSuiteMagickByteSelector.gif) 7 | 8 | # What this does 9 | 10 | Some web applications use a security feature for their file upload checks which validates the first bytes of the sent data also known as Magic Byte which 11 | 12 | allows for the identification of the file type, for instance 'GIF87a' corresponds to a file with .GIF file extension. 13 | 14 | Now lets say you try to upload ``` ``` the web application will throw an error saying that it wont accept the file 15 | 16 | However if you make it ``` GIF87a ``` in some cases the web application will think its a GIF and will allow the file to be uploaded! 17 | 18 | This extension will allow you to insert these Magic Bytes straight from burp suite into your request. 19 | 20 | # Like this extension? 21 | 22 | If you like this extension than you can show your support by giving us a Google Review 23 | 24 | and/or giving a Star to this project here on Github 25 | 26 | Google: https://g.page/r/CVTFTdnvWiKzEB0/review 27 | 28 | Trustpilot: https://www.trustpilot.com/review/websec.nl 29 | 30 | Thank you! 31 | 32 | # Ideas, Suggestions or Bug Reports? 33 | 34 | You can go to our website and submit the contact form: [websec](https://websec.nl) 35 | 36 | If as a result of your contribution we will improve the code then we will make sure to mention your name as a contributor :) 37 | --------------------------------------------------------------------------------