forked from thezedwards/sret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (45 loc) · 1.75 KB
/
main.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
from log import log_message
from sf import SFExploit
from datetime import date
import sys
def salesforce_tester(url):
log_message(f"> Testing: {url}")
vulnerability = {'accessible_objects':[],
'writable_objects':[]}
got_objects = list()
tester = SFExploit(url)
if tester.invalid:
return {'vulnerable':False}
available_objects = tester.get_objects()
# test unauth object access
log_message(f">> Testing unauth objects.")
for object_name in available_objects:
object_data = tester.get_object_items(object_name)
if object_data: # something was returned:
log_message(f">>> Found {object_name} to be accessible.")
object_data_metric = {object_name:{'total_count':object_data['totalCount']}}
vulnerability['accessible_objects'].append(object_data_metric)
got_objects.append(object_name)
# test unauth write
log_message(f">> Testing unauth write to objects")
for object_name in available_objects:
write_allowed = tester.attempt_record_create(object_name)
if write_allowed:
log_message(f">>> Found {object_name} to be potentially vulnerable.")
vulnerability['writable_objects'].append(object_name)
if len(vulnerability['accessible_objects']) > 0 or len(vulnerability['writable_objects']) > 0:
log_message(f">> Concluding testing for {url}. {url} is vulnerable.")
final_return = {'vulnerable':True, 'data':vulnerability}
return final_return
else:
log_message(f">> Concluding testing for {url}. {url} is not vulnerable")
return {'vulnerable':False}
def main(url):
today = date.today()
formatted_date = today.strftime("%m/%d/%Y")
log_message(f"Scan date: {formatted_date}")
vulnerability_rating = salesforce_tester(url)
return vulnerability_rating
if __name__ == "__main__":
url = sys.argv[1]
main(url)