Last active
December 7, 2016 09:39
-
-
Save 0xded093/5380302ce12ad077ed14f674ee7a5272 to your computer and use it in GitHub Desktop.
SP-API-Abuser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: iso-8859-15 -*- | |
import requests | |
from requests_ntlm import HttpNtlmAuth | |
from requests.auth import HTTPBasicAuth | |
import argparse | |
import curses | |
from pick import pick | |
import time | |
import getpass | |
BASE_URL = "/_api/" | |
parser = argparse.ArgumentParser(description='Microsoft Sharepoint API Browser') | |
parser.add_argument('-t','--target', help='Set the target', required=True) | |
parser.add_argument('-u','--user', help='NTLM user', required=True) | |
parser.add_argument('-p','--password', help='NTLM password', required=True) | |
parser.add_argument('-b','--brute', help='brute login id', required=False) | |
args = vars(parser.parse_args()) | |
target = args['target'] | |
user = args['user'] | |
password = args['password'] | |
def getter(target ,url): | |
r = requests.get(target+BASE_URL+url, auth=HttpNtlmAuth(user,password)) | |
return r.text | |
def picker(response): | |
import xml.dom.minidom | |
options = [] | |
xml = xml.dom.minidom.parseString(response) | |
try: | |
for node in xml.getElementsByTagName('link'): | |
api_ends = node.getAttribute('href') | |
options.append(api_ends) | |
except Exception, e: | |
raise e | |
try: | |
option, index = pick(options, "Abusing APIs of "+target+":", indicator='=>') | |
picker(getter(target, option)) | |
except: | |
print xml.toprettyxml() | |
print "###########################################################################" | |
print " _____ _____ _____ _____ _ " | |
print " / ____| __ \ /\ | __ \_ _| /\ | | " | |
print "| (___ | |__) | / \ | |__) || | / \ | |__ _ _ ___ ___ _ __ " | |
print " \___ \| ___/ / /\ \ | ___/ | | / /\ \ | '_ \| | | / __|/ _ \ '__|" | |
print " ____) | | / ____ \| | _| |_ / ____ \| |_) | |_| \__ \ __/ | " | |
print "|_____/|_| /_/ \_\_| |_____| /_/ \_\_.__/ \__,_|___/\___|_| " | |
print "###########################################################################" | |
print "[+] Launching SP API Abuser on: "+target | |
print "Press Ctrl-C to view current raw XML" | |
print "---------------------------------------------------------------------------" | |
time.sleep(2) | |
picker(getter(target, "Web")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment