├── .gitignore ├── LICENSE ├── README.md ├── requirements.txt ├── setup.py ├── sudo_root ├── __init__.py ├── crypto │ ├── __init__.py │ └── lcg.py ├── forensic │ ├── __init__.py │ └── keycode.py ├── misc │ ├── __init__.py │ ├── hamming.py │ └── zxing.py ├── pwn │ ├── __init__.py │ └── exec.py ├── stegano │ ├── __init__.py │ └── lsb_extractor.py └── version.py └── tests ├── __init__.py ├── test_assets ├── keycode.extracted ├── keycode.pcap ├── misc │ └── qrcode_wikipedia.png └── stegano │ ├── esi_sba_lsb_cycle.png │ └── lamiri_sba.png └── tests.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # IDE 107 | .vscode 108 | -------------------------------------------------------------------------------- /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 | # Sudo_root Python Library 2 | 3 | Python modules which provide a suite of useful utilities for CTFs 4 | 5 | 6 | ## Installation 7 | 8 | Install sudo_root using pip 9 | 10 | ```bash 11 | $ pip install sudo_root 12 | ``` 13 | 14 | You can also install it the last version from source 15 | 16 | ```bash 17 | $ git clone https://github.com/sudo-root-team/sudo_root 18 | $ cd sudo_root 19 | $ python3 setup.py install 20 | ``` 21 | 22 | Both will install sudo_root as well as its dependencies listed under [requirements.txt](https://github.com/sudo-root-team/sudo_root/blob/master/requirements.txt) 23 | 24 | 25 | ## License 26 | 27 | [GPLv3 License](https://github.com/sudo-root-team/sudo_root/blob/master/LICENSE) 28 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | lxml 2 | Pillow 3 | requests 4 | scapy 5 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | import os 3 | #from sudo_root import version 4 | 5 | 6 | def read(fname): 7 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 8 | 9 | 10 | requirements = read("requirements.txt").split() 11 | 12 | setuptools.setup( 13 | name="sudo_root", 14 | version="0.1",#version, 15 | url="https://github.com/sudo-root-team/sudo_root", 16 | author="Sudo_root Team", 17 | author_email="ayouben9@gmail.com", 18 | description="Library focused on CTF and cyber-security tools", 19 | long_description=read("README.md"), 20 | long_description_content_type="text/markdown", 21 | keywords="ctf pwn crypto forensic stegano web reverse engineering cyber-security security", 22 | install_requires=requirements, 23 | packages=setuptools.find_packages(), 24 | license="GPLv3" 25 | ) 26 | -------------------------------------------------------------------------------- /sudo_root/__init__.py: -------------------------------------------------------------------------------- 1 | """Provide a suite of useful utilities for CTFs""" 2 | 3 | from sudo_root.version import __version__ 4 | 5 | #This line will help the user to import with the use of the module_name (from module_name import THINGS instead of from module_name.file import THINGS) 6 | #from module_name import * 7 | from sudo_root.crypto import * 8 | from sudo_root.misc import * 9 | from sudo_root.forensic import * 10 | from sudo_root.stegano import * 11 | 12 | 13 | #List of all modules that can be imported from that modules using from module_name import *, this is useful if we use other modules in our module 14 | #You can also add this line in the module files 15 | __all__ = ["crypto", "misc", "hamming", "zxing", "lcg", "keycode", "LSBExtractor"] 16 | 17 | 18 | version = __version__ 19 | -------------------------------------------------------------------------------- /sudo_root/crypto/__init__.py: -------------------------------------------------------------------------------- 1 | """Crypto modules""" 2 | 3 | from sudo_root.crypto.lcg import Lcg 4 | 5 | __all__ = ["Lcg"] 6 | -------------------------------------------------------------------------------- /sudo_root/crypto/lcg.py: -------------------------------------------------------------------------------- 1 | """Module to break Linear Congruential Generator""" 2 | 3 | 4 | class Lcg(object): 5 | """Create LCG with a state to generate some random value, 6 | or without state to break LCG with 3 consecutive known values. 7 | 8 | Exemple: 9 | 10 | >>> from sudo_root.crypto import lcg 11 | >>> l = lcg.Lcg(multiplier, addend, mod, bits_hidden) 12 | >>> state = l.get_state(r0, r1, r2) # this are 3 consecutive output 13 | >>> l.next() give us the expected output 14 | """ 15 | 16 | def __init__(self, multiplier, addend, mod, bits_hidden, state=None): 17 | self.a = multiplier 18 | self.b = addend 19 | self.mod = mod 20 | self.hidder = 1 << bits_hidden 21 | self.state = state 22 | 23 | def get_state(self, r0, r1, r2): 24 | "break the LCG with 3 consecutive output." 25 | t = self.hidder * r1 - self.a * self.hidder * \ 26 | r0 - self.b + self.hidder - 1 27 | t %= self.mod 28 | 29 | end = (self.hidder * self.a - 1 - t) // self.mod 30 | for k in range(1, end): 31 | h = t + self.mod * k 32 | if (h % self.a) < self.hidder: 33 | state = h // self.a + self.hidder * r0 34 | if ((state * self.a + self.b) % self.mod * self.a + self.b) \ 35 | % self.mod // self.hidder == r2: 36 | self.state = state 37 | return self.state 38 | return self.state 39 | 40 | def next(self): 41 | "The next value of the LCG." 42 | self.state = (self.a * self.state + self.b) % self.mod 43 | return self.state // self.hidder 44 | -------------------------------------------------------------------------------- /sudo_root/forensic/__init__.py: -------------------------------------------------------------------------------- 1 | """Forensic modules""" 2 | 3 | from sudo_root.forensic import keycode 4 | 5 | __all__ = ["keycode"] 6 | -------------------------------------------------------------------------------- /sudo_root/forensic/keycode.py: -------------------------------------------------------------------------------- 1 | """ Module to parse pcap files which contain keyboard input reports""" 2 | from scapy.all import rdpcap 3 | 4 | KEY_CODES = { 5 | 4: "a", 6 | 5: "b", 7 | 6: "c", 8 | 7: "d", 9 | 8: "e", 10 | 9: "f", 11 | 10: "g", 12 | 11: "h", 13 | 12: "i", 14 | 13: "j", 15 | 14: "k", 16 | 15: "l", 17 | 16: "m", 18 | 17: "n", 19 | 18: "o", 20 | 19: "p", 21 | 20: "q", 22 | 21: "r", 23 | 22: "s", 24 | 23: "t", 25 | 24: "u", 26 | 25: "v", 27 | 26: "w", 28 | 27: "x", 29 | 28: "y", 30 | 29: "z", 31 | 30: "1", 32 | 31: "2", 33 | 32: "3", 34 | 33: "4", 35 | 34: "5", 36 | 35: "6", 37 | 36: "7", 38 | 37: "8", 39 | 38: "9", 40 | 39: "0", 41 | 40: "ENTER", 42 | 41: "ESCAPE", 43 | 42: "DELETE", 44 | 43: "TAB", 45 | 44: "SPACE", 46 | 45: "-", 47 | 46: "=", 48 | 47: "[", 49 | 48: "]", 50 | 49: "\\", 51 | 50: "#", 52 | 51: ";", 53 | 52: "'", 54 | 53: "`", 55 | 54: ",", 56 | 55: ".", 57 | 56: "/", 58 | 57: "CAPS LOCK", 59 | 58: "F1", 60 | 59: "F2", 61 | 60: "F3", 62 | 61: "F4", 63 | 62: "F5", 64 | 63: "F6", 65 | 64: "F7", 66 | 65: "F8", 67 | 66: "F9", 68 | 67: "F10", 69 | 68: "F11", 70 | 69: "F12", 71 | 70: "PRINT SCREEN", 72 | 71: "SCROLL LOCK", 73 | 72: "PAUSE", 74 | 73: "INSERT", 75 | 74: "HOME", 76 | 75: "PAGE UP", 77 | 76: "SUPPR", 78 | 77: "END", 79 | 78: "PAGE DOWN", 80 | 79: "RIGHT", 81 | 80: "LEFT", 82 | 81: "DOWN", 83 | 82: "UP", 84 | 83: "NUM LOCK", 85 | 84: "Keypad /1", 86 | 85: "Keypad *", 87 | 86: "Keypad -", 88 | 87: "Keypad +", 89 | 88: "Keypad Enter", 90 | 89: "Keypad 1", 91 | 90: "Keypad 2", 92 | 91: "Keypad 3", 93 | 92: "Keypad 4", 94 | 93: "Keypad 5", 95 | 94: "Keypad 6", 96 | 95: "Keypad 7", 97 | 96: "Keypad 8", 98 | 97: "Keypad 9", 99 | 98: "Keypad 0", 100 | 99: "Keypad .", 101 | 100: "\\", 102 | 101: "APPLICATION", 103 | 102: "POWER", 104 | 103: "Keypad =", 105 | 104: "F13", 106 | 105: "F14", 107 | 106: "F15", 108 | 107: "F16", 109 | 108: "F17", 110 | 109: "F18", 111 | 110: "F19", 112 | 111: "F20", 113 | 112: "F21", 114 | 113: "F22", 115 | 114: "F23", 116 | 115: "F24", 117 | 116: "EXECUTE", 118 | 117: "HELP", 119 | 118: "MENU", 120 | 119: "SELECT", 121 | 120: "STOP", 122 | 121: "AGAIN", 123 | 122: "UNDO", 124 | 123: "CUT", 125 | 124: "COPY", 126 | 125: "PASTE", 127 | 126: "FIND", 128 | 127: "MUTE", 129 | 128: "VOL UP", 130 | 129: "VOL DOWN", 131 | 130: "LOCKING CAPS LOCK", 132 | 131: "LOCKING NUM LOCK", 133 | 132: "LOCKING SCROLL LOCK", 134 | 133: "Keypad Comma", 135 | 134: "Keypad Equal Sign", 136 | 135: "International1", 137 | 136: "International2", 138 | 137: "International3", 139 | 138: "International4", 140 | 139: "International5", 141 | 140: "International6", 142 | 141: "International7", 143 | 142: "International8", 144 | 143: "International9", 145 | 144: "LANG1", 146 | 145: "LANG2", 147 | 146: "LANG3", 148 | 147: "LANG4", 149 | 148: "LANG5", 150 | 149: "LANG6", 151 | 150: "LANG7", 152 | 151: "LANG8", 153 | 152: "LANG9", 154 | 153: "ALTERNATE ERASE", 155 | 154: "SysReq/Attention", 156 | 155: "Cancel", 157 | 156: "Clear", 158 | 157: "Prior", 159 | 158: "Return", 160 | 159: "Separator", 161 | 160: "Out", 162 | 161: "Oper", 163 | 162: "Clear/Again", 164 | 163: "CrSet/Props", 165 | 164: "ExSel", 166 | # Reserved 165-175 167 | 176: "Keypad 00", 168 | 177: "Keypad 000", 169 | 178: "Thousands Separator", 170 | 179: "Decimal Separator", 171 | 180: "Currency Unit", 172 | 181: "Currency Sub-unit", 173 | 182: "Keypad (", 174 | 183: "Keypad )", 175 | 184: "Keypad {", 176 | 185: "Keypad }", 177 | 186: "Keypad Tab", 178 | 187: "Keypad BackSpace", 179 | 188: "Keypad A", 180 | 189: "Keypad B", 181 | 190: "Keypad C", 182 | 191: "Keypad D", 183 | 192: "Keypad E", 184 | 193: "Keypad F", 185 | 194: "Keypad XOR", 186 | 195: "Keypad ^", 187 | 196: "Keypad %", 188 | 197: "Keypad <", 189 | 198: "Keypad >", 190 | 199: "Keypad &", 191 | 200: "Keypad &&", 192 | 201: "Keypad |", 193 | 202: "Keypad ||", 194 | 203: "Keypad :", 195 | 204: "Keypad #", 196 | 205: "Keypad Space", 197 | 206: "Keypad @", 198 | 207: "Keypad !", 199 | 208: "Keypad Memory Store", 200 | 209: "Keypad Memory Recall", 201 | 210: "Keypad Memory Clear", 202 | 211: "Keypad Memory Add", 203 | 212: "Keypad Memory Substract", 204 | 213: "Keypad Memory Multiply", 205 | 214: "Keypad Memory Divide", 206 | 215: "Keypad +/-", 207 | 216: "Keypad Clear", 208 | 217: "Keypad Clear Entry", 209 | 218: "Keypad Binary", 210 | 219: "Keypad Octal", 211 | 220: "Keypad Decimal", 212 | 221: "Keypad Hexadecimal", 213 | # Reserved 222-223 214 | 224: "Left CTRL", 215 | 225: "Left Shift", 216 | 226: "Left ALT", 217 | 227: "Left GUI", 218 | 228: "Right CTRL", 219 | 229: "Right Shift", 220 | 230: "Right ALT", 221 | 231: "Right GUI", 222 | # Reserved 223 | } 224 | 225 | MODIFIERS = { 226 | 1: "Left CTRL", 227 | 2: "Left Shift", 228 | 4: "Left ALT", 229 | 8: "Left GUI", 230 | 16: "Right CTRL", 231 | 32: "Right Shift", 232 | 64: "Right ALT", 233 | 128: "Right GUI", 234 | } 235 | 236 | 237 | def get_key_in(pcap_file): 238 | """Extract keyboard input reports from a pcap file. 239 | The extraction depends only on the size of packets. 240 | """ 241 | pcap = rdpcap(pcap_file) 242 | in_reports = [] 243 | 244 | for p in pcap: 245 | if len(p) == 35: 246 | in_reports.append(p.load[-8:]) 247 | 248 | return in_reports 249 | 250 | 251 | def map_key_in(in_reports): 252 | """Return the keystroke according to the input reports. 253 | """ 254 | keystroke = [] 255 | 256 | for rep in in_reports: 257 | # skip null report 258 | if rep == b"\x00" * 8: 259 | continue 260 | 261 | s_keys = [] # simultaneous key 262 | modif = map_modifier(rep[0]) 263 | i = 2 264 | while rep[i]: 265 | try: 266 | s_keys.append(KEY_CODES[rep[i]]) 267 | except KeyError: 268 | s_keys.append("UNKNOWN") 269 | 270 | i += 1 271 | 272 | keystroke.append("(" + ",".join(modif) + ") " + " ".join(s_keys)) 273 | 274 | return keystroke 275 | 276 | 277 | def map_modifier(modifier): 278 | """Return modifiers from the input report first byte. 279 | """ 280 | global MODIFIERS 281 | modif = [] 282 | 283 | for m in MODIFIERS.keys(): 284 | if m & modifier: 285 | modif.append(MODIFIERS[m]) 286 | 287 | return modif 288 | 289 | 290 | def get_keystroke_from_pcap(pcap_file): 291 | """Extract keystroke from a pcap file. 292 | """ 293 | input_reports = get_key_in(pcap_file) 294 | return map_key_in(input_reports) 295 | 296 | 297 | def get_keystroke_from_data(data_file): 298 | """Extract keystroke from data file as outputed by tshark 299 | tshark -r key.pcap -T fields -e usb.capdata. 300 | """ 301 | with open(data_file) as f: 302 | data_reports = f.read().split('\n') 303 | f.close() 304 | 305 | reports = [] 306 | 307 | for d in data_reports: 308 | if len(d) != 23: 309 | continue 310 | r = map(lambda x: int(x, 16), d.split(':')) 311 | reports.append("".join(map(chr, r)).encode()) 312 | 313 | return map_key_in(reports) 314 | -------------------------------------------------------------------------------- /sudo_root/misc/__init__.py: -------------------------------------------------------------------------------- 1 | """Miscellaneous modules""" 2 | 3 | from sudo_root.misc import hamming 4 | from sudo_root.misc import zxing 5 | 6 | __all__ = ["hamming", "zxing"] 7 | -------------------------------------------------------------------------------- /sudo_root/misc/hamming.py: -------------------------------------------------------------------------------- 1 | """Module that help to deal with hamming data""" 2 | def split_15(hdata): 3 | "Split hdata to blocks of 15 bytes." 4 | dataout = [hdata[i : i+15] for i in range(0,len(hdata),15)] 5 | return dataout 6 | 7 | def split_7(hdata): 8 | "Split hdata to blocks of 7 bytes." 9 | dataout = [hdata[i : i+7] for i in range(0,len(hdata),7)] 10 | return dataout 11 | 12 | def block2bin(block): 13 | "Codify each byte of block in binary form (8 bits)." 14 | bbin =[] 15 | for b in block: 16 | bbin.append([int(c) for c in bin(ord(b))[2:].zfill(8)]) 17 | 18 | return bbin 19 | 20 | def decode_block_15(bin_block): 21 | "Decode and correct a block of 15 bytes, represented in a binary form." 22 | b = bin_block 23 | i = 0 #bit position 24 | while i < 8: 25 | 26 | h1 = b[0][i] ^ b[2][i] ^ b[4][i] ^ b[6][i] ^ b[8][i] ^ b[10][i] ^ b[12][i] ^ b[14][i] 27 | h2 = b[1][i] ^ b[2][i] ^ b[5][i] ^ b[6][i] ^ b[9][i] ^ b[10][i] ^ b[13][i] ^ b[14][i] 28 | h4 = b[3][i] ^ b[4][i] ^ b[5][i] ^ b[6][i] ^ b[11][i] ^ b[12][i] ^ b[13][i] ^ b[14][i] 29 | h8 = b[7][i] ^ b[8][i] ^ b[9][i] ^ b[10][i] ^ b[11][i] ^ b[12][i] ^ b[13][i] ^ b[14][i] 30 | 31 | key = int("".join(map(str,[h8, h4, h2, h1])), 2) 32 | 33 | if key != 0: 34 | b[key - 1][i] ^= 1 35 | else: 36 | i += 1 37 | 38 | bin_decoded = [int("".join(map(str,bit)), 2) for bit in b] 39 | 40 | data_corrected = [bin_decoded[j] for j in [2,4,5,6,8,9,10,11,12,13,14]] 41 | return "".join(map(chr,data_corrected)) 42 | 43 | def decode_15(data): 44 | """Decode and correct data using hamming_15_11 45 | Exemple: 46 | 47 | from sudo_root.misc import hamming as hamm 48 | 49 | f = open("file.hamm","rb") 50 | hdata = f.read() 51 | f.close() 52 | data_out = hamm.decode_15(hdata) 53 | f = open("decoded","wb") 54 | f.write(data_out) 55 | f.close() 56 | """ 57 | blocks = split_15(data) 58 | bin_blocks = [block2bin(b) for b in blocks] 59 | data_out = "" 60 | 61 | for b in bin_blocks: 62 | data_out += decode_block_15(b) 63 | 64 | return data_out 65 | -------------------------------------------------------------------------------- /sudo_root/misc/zxing.py: -------------------------------------------------------------------------------- 1 | """This module use the zxing.org website to decode 1D and 2D barcode""" 2 | 3 | import requests as req 4 | import lxml.html 5 | 6 | 7 | def parse_zxing_respone(response): 8 | """Parse the zxing response to get barcode decoded value. 9 | """ 10 | val_xpath = { 11 | 'Raw text': 'tr[1]/td[2]/pre', 12 | 'Raw bytes': 'tr[2]/td[2]/pre', 13 | 'Barcode format': 'tr[3]/td[2]', 14 | 'Parsed Result Type': 'tr[4]/td[2]', 15 | 'Parsed Result': 'tr[5]/td[2]/pre' 16 | } 17 | parsed = dict() 18 | html = lxml.html.fromstring(response) 19 | base_xpath = '/html/body/div/table/' 20 | for value_name, v_xpath in val_xpath.items(): 21 | try: 22 | value = html.xpath(base_xpath + v_xpath)[0].text 23 | parsed[value_name] = value 24 | except IndexError: 25 | print(value_name) 26 | parsed[value_name] = '' 27 | 28 | return parsed 29 | 30 | 31 | def decode(filename): 32 | """Decode the barcode image (filename) 33 | 34 | Exemple: 35 | 36 | >>> from sudo_root.misc import zxing 37 | >>> print zxing.decode("qr.png") 38 | """ 39 | 40 | files = dict(f=open(filename, "rb").read()) 41 | r = req.post("https://zxing.org/w/decode", files=files, timeout=5) 42 | return parse_zxing_respone(r.text) 43 | -------------------------------------------------------------------------------- /sudo_root/pwn/__init__.py: -------------------------------------------------------------------------------- 1 | """Pwn modules""" 2 | 3 | from sudo_root.pwn.exec import Remote 4 | 5 | __all__ = ["Remote"] 6 | -------------------------------------------------------------------------------- /sudo_root/pwn/exec.py: -------------------------------------------------------------------------------- 1 | """Executors objects. Provide a channel of communication with binaries, either 2 | locally running or remotely""" 3 | from socket import socket 4 | from subprocess import Popen, PIPE, STDOUT 5 | 6 | 7 | class Executor(object): 8 | """Interface of communication with remote or local binaries. 9 | Classes that inherit from this should reimplement the connect, _recv 10 | and _send methods. 11 | """ 12 | def __init__(self, line_sep=b'\n', read_size=4096): 13 | """ 14 | Args: 15 | line_sep: the line separator to use while reading stream 16 | read_size: the max number of bytes to get for each read operation 17 | """ 18 | self.line_sep = line_sep 19 | self.read_size = read_size 20 | self._buffer = b'' 21 | self.connect() 22 | 23 | def connect(self): 24 | raise NotImplementedError() 25 | 26 | def _recv(self): 27 | raise NotImplementedError() 28 | 29 | def _send(self, to_send): 30 | raise NotImplementedError() 31 | 32 | def recvline(self): 33 | """Read a line from the input stream using line_sep as line separator. 34 | """ 35 | # Read till end of line 36 | while self.line_sep not in self._buffer: 37 | self._recv() 38 | return self._recvline() 39 | 40 | def _recvline(self): 41 | """Only get the first line from the buffer, should only be called from 42 | readline as this last one make sure there is a line in the buffer. 43 | """ 44 | idx = self._buffer.find(self.line_sep) 45 | line = self._buffer[:idx] 46 | # +1 for the jumping the '\n' 47 | self._buffer = self._buffer[idx + 1:] 48 | return line 49 | 50 | def sendline(self, to_send): 51 | to_send += self.line_sep 52 | return self._send(to_send) 53 | 54 | def recv(self, n_bytes): 55 | """Read the exact number of bytes from the socket.""" 56 | if n_bytes < 0: 57 | return b'' 58 | # fill with already buffered data 59 | buffer = self._buffer[:n_bytes] 60 | self._buffer = self._buffer[n_bytes:] 61 | # get remaining bytes from the socket if needed 62 | while len(buffer) < n_bytes: 63 | to_read = n_bytes - len(buffer) 64 | self._recv() 65 | buffer += self._buffer[:to_read] 66 | self._buffer = self._buffer[to_read:] 67 | return buffer 68 | 69 | def send(self, to_send): 70 | return self._send(to_send) 71 | 72 | 73 | class Remote(Executor): 74 | """Provide a communication channel with remote services. 75 | """ 76 | def __init__(self, host, port, **kwargs): 77 | """ 78 | Args: 79 | host: domain name or ip adress to connect to 80 | port: port number to use 81 | """ 82 | 83 | self.host = host 84 | self.port = port 85 | self._socket = None 86 | super().__init__(**kwargs) 87 | 88 | def connect(self): 89 | # close socket and empty buffer if connecting again 90 | if self._socket: 91 | self._socket.close() 92 | self._buffer = b'' 93 | self._socket = socket() 94 | self._socket.connect((self.host, self.port)) 95 | 96 | def _recv(self): 97 | self._buffer += self._socket.recv(self.read_size) 98 | 99 | def _send(self, to_send): 100 | return self._socket.send(to_send) 101 | 102 | 103 | class Local(Executor): 104 | """Provide a communication channel with a local process. It takes care 105 | of executing the process. 106 | """ 107 | def __init__(self, binary_path, args=[], read_size=1, **kwargs): 108 | """ 109 | Args: 110 | binary_path: path of the binary to execute 111 | args: arguments to pass while executing the binary 112 | """ 113 | self.binary_path = binary_path 114 | self.args = args 115 | self._process = None 116 | super().__init__(read_size=read_size, **kwargs) 117 | 118 | def connect(self): 119 | """Create and the process and setup the communication channel. 120 | STDOUT and STDERR are merged together. 121 | """ 122 | # kill the process and empty buffer if creating a new one 123 | if self._process: 124 | self._process.kill() 125 | self._buffer = b'' 126 | 127 | cmd = [self.binary_path, *self.args] 128 | self._process = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) 129 | self._stdin = self._process.stdin 130 | self._stdout = self._process.stdout 131 | 132 | def _recv(self): 133 | self._buffer += self._stdout.read(self.read_size) 134 | 135 | def _send(self, to_send): 136 | count = self._stdin.write(to_send) 137 | self._stdin.flush() 138 | return count 139 | -------------------------------------------------------------------------------- /sudo_root/stegano/__init__.py: -------------------------------------------------------------------------------- 1 | """Steganography modules""" 2 | 3 | from sudo_root.stegano.lsb_extractor import LSBExtractor 4 | 5 | __all__ = ["LSBExtractor"] 6 | -------------------------------------------------------------------------------- /sudo_root/stegano/lsb_extractor.py: -------------------------------------------------------------------------------- 1 | """Module Description: TODO""" 2 | 3 | from PIL import Image 4 | 5 | 6 | class LSBExtractor(object): 7 | """docstring for lsb_extractor.""" 8 | 9 | def __init__(self, img_path): 10 | self.img = Image.open(img_path) 11 | self.data = list(self.img.getdata()) 12 | 13 | def all_lsb(self, length): 14 | out = "" 15 | for i in range(min(len(self.data), length)): 16 | out += "".join(map(lambda x: str(x & 1), self.data[i])) 17 | return out 18 | 19 | def cycle_lsb(self, length): 20 | out = "" 21 | for i in range(min(len(self.data), length)): 22 | out += str(self.data[i][i % 3] & 1) 23 | return out 24 | 25 | @staticmethod 26 | def bits2bytes(bits): 27 | out = "" 28 | for i in range(0, len(bits)/8, 8): 29 | out += chr(int(bits[i:i+8], 2)) 30 | return out 31 | -------------------------------------------------------------------------------- /sudo_root/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1' 2 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudo-root-team/sudo_root/e7ec0d4d5c52791660450833139f8859c0ba0993/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_assets/keycode.extracted: -------------------------------------------------------------------------------- 1 | 01:00:fa:54:25:4a:00:00:00:00 2 | 01:00:fa:54:00:4a:00:00:00:00 3 | 01:00:50:55:42:49:00:00:00:00 4 | 01:00:e0:55:c7:47:00:00:00:00 5 | 01:00:00:57:f6:44:00:00:00:00 6 | 01:00:76:58:da:41:00:00:00:00 7 | 01:00:d0:59:25:3e:00:00:00:00 8 | 01:00:d6:5b:aa:38:00:00:00:00 9 | 01:00:4c:5d:aa:34:00:00:00:00 10 | 01:00:e0:5e:ed:2f:00:00:00:00 11 | 01:00:1c:60:97:2a:00:00:00:00 12 | 01:00:e6:60:2f:27:00:00:00:00 13 | 01:00:06:62:09:23:00:00:00:00 14 | 01:00:cf:62:38:20:00:00:00:00 15 | 01:00:b6:63:aa:1c:00:00:00:00 16 | 01:00:f2:64:1c:19:00:00:00:00 17 | 01:00:f6:65:da:15:00:00:00:00 18 | 01:00:dc:66:e3:12:00:00:00:00 19 | 01:00:89:67:c7:0f:00:00:00:00 20 | 01:00:8c:68:38:0c:00:00:00:00 21 | 01:00:e2:68:00:0a:00:00:00:00 22 | 01:00:55:69:a1:07:00:00:00:00 23 | 01:00:55:69:4b:06:00:00:00:00 24 | 01:00:55:69:1c:05:00:00:00:00 25 | 01:00:55:69:38:04:00:00:00:00 26 | 01:00:55:69:a1:03:00:00:00:00 27 | 01:00:55:69:55:03:00:00:00:00 28 | 01:00:55:69:09:03:00:00:00:00 29 | 01:00:55:69:71:02:00:00:00:00 30 | 01:00:55:69:25:02:00:00:00:00 31 | 01:00:55:69:00:02:00:00:00:00 32 | 01:00:55:69:b4:01:00:00:00:00 33 | 01:00:55:69:8e:01:00:00:00:00 34 | 01:00:39:69:68:01:00:00:00:00 35 | 01:00:39:69:42:01:00:00:00:00 36 | 01:00:39:69:1c:01:00:00:00:00 37 | 01:00:ff:68:aa:00:00:00:00:00 38 | 01:00:c5:68:5e:00:00:00:00:00 39 | 01:00:6f:68:00:00:00:00:00:00 40 | 01:00:cb:33:b4:15:00:00:00:00 41 | 01:00:22:2b:d0:18:00:00:00:00 42 | 01:00:72:29:42:19:00:00:00:00 43 | 01:00:df:27:b4:19:00:00:00:00 44 | 01:00:86:26:25:1a:00:00:00:00 45 | 01:00:66:25:71:1a:00:00:00:00 46 | 01:00:46:24:09:1b:00:00:00:00 47 | 01:00:26:23:a1:1b:00:00:00:00 48 | 01:00:06:22:ed:1b:00:00:00:00 49 | 01:00:76:21:38:1c:00:00:00:00 50 | 01:00:1f:21:84:1c:00:00:00:00 51 | 01:00:8f:20:1c:1d:00:00:00:00 52 | 01:00:39:20:42:1d:00:00:00:00 53 | 01:00:e3:1f:8e:1d:00:00:00:00 54 | 01:00:8c:1f:b4:1d:00:00:00:00 55 | 01:00:70:1f:da:1d:00:00:00:00 56 | 01:00:36:1f:da:1d:00:00:00:00 57 | 01:00:36:1f:00:1e:00:00:00:00 58 | 01:00:36:1f:25:1e:00:00:00:00 59 | 01:00:36:1f:00:1e:00:00:00:00 60 | 01:01:36:1f:00:1e:00:00:00:00 61 | 01:00:36:1f:00:1e:00:00:00:00 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 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 02:00:00:00 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 02:00:00:00 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 02:00:00:00 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 00:00:1a:00:00:00:00:00 303 | 00:00:00:00:00:00:00:00 304 | 00:00:28:00:00:00:00:00 305 | 00:00:00:00:00:00:00:00 306 | 00:00:0e:00:00:00:00:00 307 | 00:00:00:00:00:00:00:00 308 | 00:00:28:00:00:00:00:00 309 | 00:00:00:00:00:00:00:00 310 | 00:00:09:00:00:00:00:00 311 | 00:00:00:00:00:00:00:00 312 | 00:00:28:00:00:00:00:00 313 | 00:00:00:00:00:00:00:00 314 | 00:00:05:00:00:00:00:00 315 | 00:00:00:00:00:00:00:00 316 | 00:00:28:00:00:00:00:00 317 | 00:00:00:00:00:00:00:00 318 | 00:00:20:00:00:00:00:00 319 | 00:00:00:00:00:00:00:00 320 | 00:00:34:00:00:00:00:00 321 | 00:00:00:00:00:00:00:00 322 | 00:00:52:00:00:00:00:00 323 | 00:00:00:00:00:00:00:00 324 | 00:00:2f:00:00:00:00:00 325 | 00:00:00:00:00:00:00:00 326 | 00:00:52:00:00:00:00:00 327 | 00:00:00:00:00:00:00:00 328 | 00:00:0f:00:00:00:00:00 329 | 00:00:00:00:00:00:00:00 330 | 00:00:52:00:00:00:00:00 331 | 00:00:00:00:00:00:00:00 332 | 02:00:00:00:00:00:00:00 333 | 02:00:20:00:00:00:00:00 334 | 02:00:00:00:00:00:00:00 335 | 00:00:00:00:00:00:00:00 336 | 00:00:52:00:00:00:00:00 337 | 00:00:00:00:00:00:00:00 338 | 02:00:00:00:00:00:00:00 339 | 02:00:2f:00:00:00:00:00 340 | 02:00:00:00:00:00:00:00 341 | 00:00:00:00:00:00:00:00 342 | 00:00:1a:00:00:00:00:00 343 | 00:00:00:00:00:00:00:00 344 | 02:00:00:00:00:00:00:00 345 | 02:00:21:00:00:00:00:00 346 | 02:00:00:00:00:00:00:00 347 | 00:00:00:00:00:00:00:00 348 | 00:00:51:00:00:00:00:00 349 | 00:00:00:00:00:00:00:00 350 | 02:00:00:00:00:00:00:00 351 | 02:00:37:00:00:00:00:00 352 | 02:00:00:00:00:00:00:00 353 | 00:00:00:00:00:00:00:00 354 | 00:00:05:00:00:00:00:00 355 | 00:00:00:00:00:00:00:00 356 | 00:00:51:00:00:00:00:00 357 | 00:00:00:00:00:00:00:00 358 | 00:00:04:00:00:00:00:00 359 | 00:00:00:00:00:00:00:00 360 | 00:00:0a:00:00:00:00:00 361 | 00:00:00:00:00:00:00:00 362 | 00:00:51:00:00:00:00:00 363 | 00:00:00:00:00:00:00:00 364 | 00:00:2f:00:00:00:00:00 365 | 00:00:00:00:00:00:00:00 366 | 00:00:08:00:00:00:00:00 367 | 00:00:00:00:00:00:00:00 368 | 00:00:51:00:00:00:00:00 369 | 00:00:00:00:00:00:00:00 370 | 00:00:06:00:00:00:00:00 371 | 00:00:00:00:00:00:00:00 372 | 00:00:0c:00:00:00:00:00 373 | 00:00:00:00:00:00:00:00 374 | 00:00:37:00:00:00:00:00 375 | 00:00:00:00:00:00:00:00 376 | 00:00:2f:00:00:00:00:00 377 | 00:00:00:00:00:00:00:00 378 | 00:00:52:00:00:00:00:00 379 | 00:00:00:00:00:00:00:00 380 | 00:00:2f:00:00:00:00:00 381 | 00:00:00:00:00:00:00:00 382 | 00:00:09:00:00:00:00:00 383 | 00:00:00:00:00:00:00:00 384 | 00:00:52:00:00:00:00:00 385 | 00:00:00:00:00:00:00:00 386 | 02:00:00:00:00:00:00:00 387 | 02:00:2f:00:00:00:00:00 388 | 02:00:00:00:00:00:00:00 389 | 00:00:00:00:00:00:00:00 390 | 00:00:0e:00:00:00:00:00 391 | 00:00:00:00:00:00:00:00 392 | 00:00:52:00:00:00:00:00 393 | 00:00:00:00:00:00:00:00 394 | 00:00:11:00:00:00:00:00 395 | 00:00:00:00:00:00:00:00 396 | 02:00:00:00:00:00:00:00 397 | 02:00:21:00:00:00:00:00 398 | 02:00:00:00:00:00:00:00 399 | 00:00:00:00:00:00:00:00 400 | 00:00:52:00:00:00:00:00 401 | 00:00:00:00:00:00:00:00 402 | 00:00:0d:00:00:00:00:00 403 | 00:00:00:00:00:00:00:00 404 | 00:00:18:00:00:00:00:00 405 | 00:00:00:00:00:00:00:00 406 | 02:00:00:00:00:00:00:00 407 | 02:00:30:00:00:00:00:00 408 | 02:00:00:00:00:00:00:00 409 | 00:00:00:00:00:00:00:00 410 | 00:00:51:00:00:00:00:00 411 | 00:00:00:00:00:00:00:00 412 | 02:00:00:00:00:00:00:00 413 | 02:00:33:00:00:00:00:00 414 | 02:00:00:00:00:00:00:00 415 | 00:00:00:00:00:00:00:00 416 | 00:00:51:00:00:00:00:00 417 | 00:00:00:00:00:00:00:00 418 | 00:00:20:00:00:00:00:00 419 | 00:00:00:00:00:00:00:00 420 | 00:00:51:00:00:00:00:00 421 | 00:00:00:00:00:00:00:00 422 | 00:00:18:00:00:00:00:00 423 | 00:00:00:00:00:00:00:00 424 | 00:00:51:00:00:00:00:00 425 | 00:00:00:00:00:00:00:00 426 | 02:00:00:00:00:00:00:00 427 | 02:00:22:00:00:00:00:00 428 | 02:00:00:00:00:00:00:00 429 | 00:00:00:00:00:00:00:00 430 | 00:00:2e:00:00:00:00:00 431 | 00:00:00:00:00:00:00:00 432 | 00:00:52:00:00:00:00:00 433 | 00:00:00:00:00:00:00:00 434 | 02:00:00:00:00:00:00:00 435 | 02:00:32:00:00:00:00:00 436 | 02:00:00:00:00:00:00:00 437 | 00:00:00:00:00:00:00:00 438 | 00:00:52:00:00:00:00:00 439 | 00:00:00:00:00:00:00:00 440 | 00:00:1c:00:00:00:00:00 441 | 00:00:00:00:00:00:00:00 442 | 00:00:52:00:00:00:00:00 443 | 00:00:00:00:00:00:00:00 444 | 00:00:23:00:00:00:00:00 445 | 00:00:00:00:00:00:00:00 446 | 00:00:52:00:00:00:00:00 447 | 00:00:00:00:00:00:00:00 448 | 00:00:36:00:00:00:00:00 449 | 00:00:00:00:00:00:00:00 450 | 00:00:34:00:00:00:00:00 451 | 00:00:00:00:00:00:00:00 452 | 00:00:51:00:00:00:00:00 453 | 00:00:00:00:00:00:00:00 454 | 00:00:13:00:00:00:00:00 455 | 00:00:00:00:00:00:00:00 456 | 00:00:51:00:00:00:00:00 457 | 00:00:00:00:00:00:00:00 458 | 00:00:05:00:00:00:00:00 459 | 00:00:00:00:00:00:00:00 460 | 00:00:51:00:00:00:00:00 461 | 00:00:00:00:00:00:00:00 462 | 00:00:24:00:00:00:00:00 463 | 00:00:00:00:00:00:00:00 464 | 00:00:51:00:00:00:00:00 465 | 00:00:00:00:00:00:00:00 466 | 02:00:00:00:00:00:00:00 467 | 02:00:22:00:00:00:00:00 468 | 02:00:00:00:00:00:00:00 469 | 00:00:00:00:00:00:00:00 470 | 02:00:00:00:00:00:00:00 471 | 02:00:24:00:00:00:00:00 472 | 02:00:00:00:00:00:00:00 473 | 00:00:00:00:00:00:00:00 474 | 00:00:52:00:00:00:00:00 475 | 00:00:00:00:00:00:00:00 476 | 00:00:07:00:00:00:00:00 477 | 00:00:00:00:00:00:00:00 478 | 00:00:52:00:00:00:00:00 479 | 00:00:00:00:00:00:00:00 480 | 00:00:27:00:00:00:00:00 481 | 00:00:00:00:00:00:00:00 482 | 00:00:52:00:00:00:00:00 483 | 00:00:00:00:00:00:00:00 484 | 00:00:0d:00:00:00:00:00 485 | 00:00:00:00:00:00:00:00 486 | 00:00:52:00:00:00:00:00 487 | 00:00:00:00:00:00:00:00 488 | 00:00:13:00:00:00:00:00 489 | 00:00:00:00:00:00:00:00 490 | 00:00:17:00:00:00:00:00 491 | 00:00:00:00:00:00:00:00 492 | 00:00:51:00:00:00:00:00 493 | 00:00:00:00:00:00:00:00 494 | 00:00:0c:00:00:00:00:00 495 | 00:00:00:00:00:00:00:00 496 | 00:00:51:00:00:00:00:00 497 | 00:00:00:00:00:00:00:00 498 | 00:00:04:00:00:00:00:00 499 | 00:00:00:00:00:00:00:00 500 | 00:00:51:00:00:00:00:00 501 | 00:00:00:00:00:00:00:00 502 | 00:00:2f:00:00:00:00:00 503 | 00:00:00:00:00:00:00:00 504 | 00:00:51:00:00:00:00:00 505 | 00:00:00:00:00:00:00:00 506 | 00:00:0e:00:00:00:00:00 507 | 00:00:00:00:00:00:00:00 508 | 02:00:00:00:00:00:00:00 509 | 02:00:26:00:00:00:00:00 510 | 02:00:00:00:00:00:00:00 511 | 00:00:00:00:00:00:00:00 512 | 00:00:52:00:00:00:00:00 513 | 00:00:00:00:00:00:00:00 514 | 00:00:2e:00:00:00:00:00 515 | 00:00:00:00:00:00:00:00 516 | 00:00:52:00:00:00:00:00 517 | 00:00:00:00:00:00:00:00 518 | 00:00:15:00:00:00:00:00 519 | 00:00:00:00:00:00:00:00 520 | 00:00:52:00:00:00:00:00 521 | 00:00:00:00:00:00:00:00 522 | 00:00:10:00:00:00:00:00 523 | 00:00:00:00:00:00:00:00 524 | 00:00:52:00:00:00:00:00 525 | 00:00:00:00:00:00:00:00 526 | 00:00:30:00:00:00:00:00 527 | 00:00:00:00:00:00:00:00 528 | 00:00:2e:00:00:00:00:00 529 | 00:00:00:00:00:00:00:00 530 | 00:00:51:00:00:00:00:00 531 | 00:00:00:00:00:00:00:00 532 | 00:00:27:00:00:00:00:00 533 | 00:00:00:00:00:00:00:00 534 | 00:00:51:00:00:00:00:00 535 | 00:00:00:00:00:00:00:00 536 | 00:00:07:00:00:00:00:00 537 | 00:00:00:00:00:00:00:00 538 | 00:00:51:00:00:00:00:00 539 | 00:00:00:00:00:00:00:00 540 | 02:00:00:00:00:00:00:00 541 | 02:00:37:00:00:00:00:00 542 | 02:00:00:00:00:00:00:00 543 | 00:00:00:00:00:00:00:00 544 | 00:00:51:00:00:00:00:00 545 | 00:00:00:00:00:00:00:00 546 | 00:00:0f:00:00:00:00:00 547 | 00:00:00:00:00:00:00:00 548 | 00:00:06:00:00:00:00:00 549 | 00:00:00:00:00:00:00:00 550 | 00:00:52:00:00:00:00:00 551 | 00:00:00:00:00:00:00:00 552 | 02:00:00:00:00:00:00:00 553 | 02:00:25:00:00:00:00:00 554 | 02:00:00:00:00:00:00:00 555 | 00:00:00:00:00:00:00:00 556 | 00:00:52:00:00:00:00:00 557 | 00:00:00:00:00:00:00:00 558 | 02:00:00:00:00:00:00:00 559 | 02:00:2d:00:00:00:00:00 560 | 02:00:00:00:00:00:00:00 561 | 00:00:00:00:00:00:00:00 562 | 00:00:52:00:00:00:00:00 563 | 00:00:00:00:00:00:00:00 564 | 02:00:00:00:00:00:00:00 565 | 02:00:2f:00:00:00:00:00 566 | 02:00:00:00:00:00:00:00 567 | 00:00:00:00:00:00:00:00 568 | 00:00:52:00:00:00:00:00 569 | 00:00:00:00:00:00:00:00 570 | 00:00:0d:00:00:00:00:00 571 | 00:00:00:00:00:00:00:00 572 | 02:00:00:00:00:00:00:00 573 | 02:00:22:00:00:00:00:00 574 | 02:00:00:00:00:00:00:00 575 | 00:00:00:00:00:00:00:00 576 | 00:00:51:00:00:00:00:00 577 | 00:00:00:00:00:00:00:00 578 | 00:00:18:00:00:00:00:00 579 | 00:00:00:00:00:00:00:00 580 | 00:00:51:00:00:00:00:00 581 | 00:00:00:00:00:00:00:00 582 | 00:00:16:00:00:00:00:00 583 | 00:00:00:00:00:00:00:00 584 | 00:00:51:00:00:00:00:00 585 | 00:00:00:00:00:00:00:00 586 | 02:00:00:00:00:00:00:00 587 | 02:00:26:00:00:00:00:00 588 | 02:00:00:00:00:00:00:00 589 | 00:00:00:00:00:00:00:00 590 | 00:00:51:00:00:00:00:00 591 | 00:00:00:00:00:00:00:00 592 | 02:00:00:00:00:00:00:00 593 | 02:00:25:00:00:00:00:00 594 | 02:00:00:00:00:00:00:00 595 | 00:00:00:00:00:00:00:00 596 | 00:00:1f:00:00:00:00:00 597 | 00:00:00:00:00:00:00:00 598 | 00:00:52:00:00:00:00:00 599 | 00:00:00:00:00:00:00:00 600 | 00:00:27:00:00:00:00:00 601 | 00:00:00:00:00:00:00:00 602 | 00:00:52:00:00:00:00:00 603 | 00:00:00:00:00:00:00:00 604 | 00:00:11:00:00:00:00:00 605 | 00:00:00:00:00:00:00:00 606 | 00:00:52:00:00:00:00:00 607 | 00:00:00:00:00:00:00:00 608 | 00:00:34:00:00:00:00:00 609 | 00:00:00:00:00:00:00:00 610 | 00:00:52:00:00:00:00:00 611 | 00:00:00:00:00:00:00:00 612 | 00:00:33:00:00:00:00:00 613 | 00:00:00:00:00:00:00:00 614 | 00:00:26:00:00:00:00:00 615 | 00:00:00:00:00:00:00:00 616 | 00:00:51:00:00:00:00:00 617 | 00:00:00:00:00:00:00:00 618 | 00:00:0b:00:00:00:00:00 619 | 00:00:00:00:00:00:00:00 620 | 00:00:51:00:00:00:00:00 621 | 00:00:00:00:00:00:00:00 622 | 00:00:21:00:00:00:00:00 623 | 00:00:00:00:00:00:00:00 624 | 00:00:51:00:00:00:00:00 625 | 00:00:00:00:00:00:00:00 626 | 00:00:30:00:00:00:00:00 627 | 00:00:00:00:00:00:00:00 628 | 00:00:51:00:00:00:00:00 629 | 00:00:00:00:00:00:00:00 630 | 00:00:1c:00:00:00:00:00 631 | 00:00:00:00:00:00:00:00 632 | 00:00:21:00:00:00:00:00 633 | 00:00:00:00:00:00:00:00 634 | 00:00:52:00:00:00:00:00 635 | 00:00:00:00:00:00:00:00 636 | 00:00:34:00:00:00:00:00 637 | 00:00:00:00:00:00:00:00 638 | 00:00:52:00:00:00:00:00 639 | 00:00:00:00:00:00:00:00 640 | 00:00:0e:00:00:00:00:00 641 | 00:00:00:00:00:00:00:00 642 | 00:00:52:00:00:00:00:00 643 | 00:00:00:00:00:00:00:00 644 | 00:00:33:00:00:00:00:00 645 | 00:00:00:00:00:00:00:00 646 | 00:00:52:00:00:00:00:00 647 | 00:00:00:00:00:00:00:00 648 | 02:00:00:00:00:00:00:00 649 | 02:00:2e:00:00:00:00:00 650 | 02:00:00:00:00:00:00:00 651 | 00:00:00:00:00:00:00:00 652 | 00:00:13:00:00:00:00:00 653 | 00:00:00:00:00:00:00:00 654 | 00:00:51:00:00:00:00:00 655 | 00:00:00:00:00:00:00:00 656 | 00:00:09:00:00:00:00:00 657 | 00:00:00:00:00:00:00:00 658 | 00:00:51:00:00:00:00:00 659 | 00:00:00:00:00:00:00:00 660 | 00:00:08:00:00:00:00:00 661 | 00:00:00:00:00:00:00:00 662 | 00:00:51:00:00:00:00:00 663 | 00:00:00:00:00:00:00:00 664 | 02:00:00:00:00:00:00:00 665 | 02:00:21:00:00:00:00:00 666 | 02:00:00:00:00:00:00:00 667 | 00:00:00:00:00:00:00:00 668 | 00:00:51:00:00:00:00:00 669 | 00:00:00:00:00:00:00:00 670 | 02:00:00:00:00:00:00:00 671 | 02:00:1e:00:00:00:00:00 672 | 02:00:00:00:00:00:00:00 673 | 00:00:00:00:00:00:00:00 674 | 02:00:00:00:00:00:00:00 675 | 02:00:30:00:00:00:00:00 676 | 02:00:00:00:00:00:00:00 677 | 00:00:00:00:00:00:00:00 678 | 00:00:52:00:00:00:00:00 679 | 00:00:00:00:00:00:00:00 680 | 00:00:1e:00:00:00:00:00 681 | 00:00:00:00:00:00:00:00 682 | 00:00:52:00:00:00:00:00 683 | 00:00:00:00:00:00:00:00 684 | 02:00:00:00:00:00:00:00 685 | 02:00:2d:00:00:00:00:00 686 | 02:00:00:00:00:00:00:00 687 | 00:00:00:00:00:00:00:00 688 | 00:00:52:00:00:00:00:00 689 | 00:00:00:00:00:00:00:00 690 | 00:00:0e:00:00:00:00:00 691 | 00:00:00:00:00:00:00:00 692 | 00:00:52:00:00:00:00:00 693 | 00:00:00:00:00:00:00:00 694 | 00:00:16:00:00:00:00:00 695 | 00:00:00:00:00:00:00:00 696 | 02:00:00:00:00:00:00:00 697 | 02:00:24:00:00:00:00:00 698 | 02:00:00:00:00:00:00:00 699 | 00:00:00:00:00:00:00:00 700 | 00:00:51:00:00:00:00:00 701 | 00:00:00:00:00:00:00:00 702 | 00:00:16:00:00:00:00:00 703 | 00:00:00:00:00:00:00:00 704 | 00:00:51:00:00:00:00:00 705 | 00:00:00:00:00:00:00:00 706 | 00:00:1f:00:00:00:00:00 707 | 00:00:00:00:00:00:00:00 708 | 00:00:51:00:00:00:00:00 709 | 00:00:00:00:00:00:00:00 710 | 00:00:06:00:00:00:00:00 711 | 00:00:00:00:00:00:00:00 712 | 00:00:51:00:00:00:00:00 713 | 00:00:00:00:00:00:00:00 714 | 02:00:00:00:00:00:00:00 715 | 02:00:22:00:00:00:00:00 716 | 02:00:00:00:00:00:00:00 717 | 00:00:00:00:00:00:00:00 718 | 00:00:14:00:00:00:00:00 719 | 00:00:00:00:00:00:00:00 720 | 00:00:52:00:00:00:00:00 721 | 00:00:00:00:00:00:00:00 722 | 02:00:00:00:00:00:00:00 723 | 02:00:21:00:00:00:00:00 724 | 02:00:00:00:00:00:00:00 725 | 00:00:00:00:00:00:00:00 726 | 00:00:52:00:00:00:00:00 727 | 00:00:00:00:00:00:00:00 728 | 00:00:37:00:00:00:00:00 729 | 00:00:00:00:00:00:00:00 730 | 00:00:52:00:00:00:00:00 731 | 00:00:00:00:00:00:00:00 732 | 02:00:00:00:00:00:00:00 733 | 02:00:1e:00:00:00:00:00 734 | 02:00:00:00:00:00:00:00 735 | 00:00:00:00:00:00:00:00 736 | 00:00:52:00:00:00:00:00 737 | 00:00:00:00:00:00:00:00 738 | 02:00:00:00:00:00:00:00 739 | 02:00:20:00:00:00:00:00 740 | 02:00:00:00:00:00:00:00 741 | 00:00:00:00:00:00:00:00 742 | 00:00:36:00:00:00:00:00 743 | 00:00:00:00:00:00:00:00 744 | 00:00:51:00:00:00:00:00 745 | 00:00:00:00:00:00:00:00 746 | 00:00:16:00:00:00:00:00 747 | 00:00:00:00:00:00:00:00 748 | 00:00:51:00:00:00:00:00 749 | 00:00:00:00:00:00:00:00 750 | 00:00:27:00:00:00:00:00 751 | 00:00:00:00:00:00:00:00 752 | 00:00:51:00:00:00:00:00 753 | 00:00:00:00:00:00:00:00 754 | 00:00:06:00:00:00:00:00 755 | 00:00:00:00:00:00:00:00 756 | 00:00:51:00:00:00:00:00 757 | 00:00:00:00:00:00:00:00 758 | 00:00:1d:00:00:00:00:00 759 | 00:00:00:00:00:00:00:00 760 | 00:00:20:00:00:00:00:00 761 | 00:00:00:00:00:00:00:00 762 | 00:00:52:00:00:00:00:00 763 | 00:00:00:00:00:00:00:00 764 | 00:00:08:00:00:00:00:00 765 | 00:00:00:00:00:00:00:00 766 | 00:00:52:00:00:00:00:00 767 | 00:00:00:00:00:00:00:00 768 | 02:00:00:00:00:00:00:00 769 | 02:00:30:00:00:00:00:00 770 | 02:00:00:00:00:00:00:00 771 | 00:00:00:00:00:00:00:00 772 | 00:00:52:00:00:00:00:00 773 | 00:00:00:00:00:00:00:00 774 | 00:00:2d:00:00:00:00:00 775 | 00:00:00:00:00:00:00:00 776 | 00:00:52:00:00:00:00:00 777 | 00:00:00:00:00:00:00:00 778 | 00:00:0c:00:00:00:00:00 779 | 00:00:00:00:00:00:00:00 780 | 02:00:04:00:00:00:00:00:00:00 781 | 02:00:08:00:00:00:00:00:00:00 782 | 02:00:0f:00:02:00:00:00:00:00 783 | 02:00:0f:00:07:00:00:00:00:00 784 | 01:00:12:26:00:22:00:00:00:00 785 | 01:00:4f:27:d0:24:00:00:00:00 786 | 01:00:df:27:4b:26:00:00:00:00 787 | 01:00:39:29:84:28:00:00:00:00 788 | 01:00:cc:2a:25:2a:00:00:00:00 789 | 01:00:5f:2c:12:2c:00:00:00:00 790 | 01:00:b8:2d:71:2e:00:00:00:00 791 | 01:00:bc:2e:a1:2f:00:00:00:00 792 | 01:00:32:30:da:31:00:00:00:00 793 | 01:00:a8:31:55:33:00:00:00:00 794 | 01:00:c8:32:38:34:00:00:00:00 795 | 01:00:78:34:b4:35:00:00:00:00 796 | 01:00:62:36:2f:37:00:00:00:00 797 | 01:00:d5:36:12:38:00:00:00:00 798 | 01:00:bb:37:68:39:00:00:00:00 799 | 01:00:c1:39:55:3b:00:00:00:00 800 | 01:00:38:3b:84:3c:00:00:00:00 801 | 01:00:3b:3c:da:3d:00:00:00:00 802 | 01:00:ae:3c:bd:3e:00:00:00:00 803 | 01:00:94:3d:a1:3f:00:00:00:00 804 | 01:00:24:3e:12:40:00:00:00:00 805 | 01:00:d1:3e:d0:40:00:00:00:00 806 | 01:00:28:3f:f6:40:00:00:00:00 807 | 01:00:9b:3f:42:41:00:00:00:00 808 | 01:00:f1:3f:42:41:00:00:00:00 809 | 01:00:0e:40:68:41:00:00:00:00 810 | 01:00:47:40:68:41:00:00:00:00 811 | 01:00:64:40:8e:41:00:00:00:00 812 | 01:00:bb:40:8e:41:00:00:00:00 813 | 01:00:f4:40:b4:41:00:00:00:00 814 | 01:00:4b:41:00:42:00:00:00:00 815 | 01:00:84:41:4b:42:00:00:00:00 816 | 01:00:a1:41:71:42:00:00:00:00 817 | 01:00:f7:41:bd:42:00:00:00:00 818 | 01:00:31:42:09:43:00:00:00:00 819 | 01:00:6b:42:2f:43:00:00:00:00 820 | 01:00:fb:42:c7:43:00:00:00:00 821 | 01:00:a7:43:aa:44:00:00:00:00 822 | 01:00:37:44:00:46:00:00:00:00 823 | 01:00:3a:45:c7:47:00:00:00:00 824 | 01:00:77:46:b4:49:00:00:00:00 825 | 01:00:41:47:55:4b:00:00:00:00 826 | 01:00:ee:47:84:4c:00:00:00:00 827 | 01:00:7d:48:68:4d:00:00:00:00 828 | 01:00:f1:48:4b:4e:00:00:00:00 829 | 01:00:47:49:09:4f:00:00:00:00 830 | 01:00:ba:49:a1:4f:00:00:00:00 831 | 01:00:d7:49:ed:4f:00:00:00:00 832 | 01:00:2d:4a:38:50:00:00:00:00 833 | 01:00:4a:4a:38:50:00:00:00:00 834 | 01:01:4a:4a:38:50:00:00:00:00 835 | 01:00:4a:4a:38:50:00:00:00:00 836 | -------------------------------------------------------------------------------- /tests/test_assets/keycode.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudo-root-team/sudo_root/e7ec0d4d5c52791660450833139f8859c0ba0993/tests/test_assets/keycode.pcap -------------------------------------------------------------------------------- /tests/test_assets/misc/qrcode_wikipedia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudo-root-team/sudo_root/e7ec0d4d5c52791660450833139f8859c0ba0993/tests/test_assets/misc/qrcode_wikipedia.png -------------------------------------------------------------------------------- /tests/test_assets/stegano/esi_sba_lsb_cycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudo-root-team/sudo_root/e7ec0d4d5c52791660450833139f8859c0ba0993/tests/test_assets/stegano/esi_sba_lsb_cycle.png -------------------------------------------------------------------------------- /tests/test_assets/stegano/lamiri_sba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudo-root-team/sudo_root/e7ec0d4d5c52791660450833139f8859c0ba0993/tests/test_assets/stegano/lamiri_sba.png -------------------------------------------------------------------------------- /tests/tests.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | from sudo_root.stegano import LSBExtractor 4 | from sudo_root.misc import zxing 5 | from sudo_root.crypto import Lcg 6 | from sudo_root.forensic import keycode 7 | 8 | 9 | def relative_path(path): 10 | return os.path.join(os.path.dirname(__file__), path) 11 | 12 | 13 | class TestLSBExtractor(unittest.TestCase): 14 | 15 | def test_all_lsb(self): 16 | img_path = relative_path("test_assets/stegano/lamiri_sba.png") 17 | 18 | lsb = LSBExtractor(img_path) 19 | out = lsb.all_lsb(40) 20 | 21 | msg = "" 22 | for i in range(0, len(out), 8): 23 | msg += chr(int(out[i:i+8], 2)) 24 | 25 | self.assertEqual(msg, "Hello World !!!") 26 | 27 | def test_all_cycle(self): 28 | img_path = relative_path("test_assets/stegano/esi_sba_lsb_cycle.png") 29 | 30 | lsb = LSBExtractor(img_path) 31 | out = lsb.cycle_lsb(192) 32 | 33 | msg = "" 34 | for i in range(0, len(out), 8): 35 | msg += chr(int(out[i:i+8], 2)) 36 | 37 | self.assertEqual(msg, "LSB cycle hidden message") 38 | 39 | 40 | class TestZxing(unittest.TestCase): 41 | 42 | def test_decode(self): 43 | img_path = relative_path("test_assets/misc/qrcode_wikipedia.png") 44 | 45 | result = zxing.decode(img_path) 46 | raw_text = result["Raw text"] 47 | self.assertEqual(raw_text, "http://en.m.wikipedia.org") 48 | 49 | 50 | class TestLcg(unittest.TestCase): 51 | 52 | def test_lcg(self): 53 | lcg = Lcg(0x66e158441b6995, 0xB, 1 << 85, 53) 54 | state = lcg.get_state(2752470789, 3367609997, 1185935283) 55 | next_values = [lcg.next() for _ in range(4)] 56 | 57 | expected_next_values = [3367609997, 1185935283, 587646151, 4198508994] 58 | 59 | self.assertEqual(state, 24792052844465667546212387) 60 | self.assertEqual(next_values, expected_next_values) 61 | 62 | 63 | class TestKeycode(unittest.TestCase): 64 | 65 | def test_extract_keycode(self): 66 | keycode_pcap_path = relative_path("test_assets/keycode.pcap") 67 | extracted_keycode_path = relative_path("test_assets/keycode.extracted") 68 | keycodes = keycode.get_keystroke_from_pcap(keycode_pcap_path) 69 | target_keycodes = keycode.get_keystroke_from_data( 70 | extracted_keycode_path) 71 | self.assertEqual(keycodes, target_keycodes) 72 | 73 | 74 | if __name__ == '__main__': 75 | unittest.main() 76 | --------------------------------------------------------------------------------