Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="iso-8859-2" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="UAC INVITE + call">
<send retrans="500">
<![CDATA[
INVITE sip:[field3]@[field4]:5061;transport=tls SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
@giavac
giavac / unescape_jsonify_cstring.py
Created July 12, 2023 15:37
Convert a multiline string into a CString usable with C code
#!/usr/local/bin/python3
import json
import argparse
def rewrite_as_c_string(json_str):
data = json.loads(json_str)
formatted_json = json.dumps(data, indent=4)
c_string = '"' + formatted_json.replace('"', '\\"').replace('\n', '\\n"\n"') + '"'
return c_string
@giavac
giavac / extract_opus_and_decode.py
Created July 5, 2023 14:58
Extracts the RTP payload and decodes it into a wav file
import pyshark
import opuslib
import wave
import argparse
FRAME_SIZE = 960
SAMPLE_RATE = 48000
CHANNEL_COUNT = 1
SAMPLE_WIDTH = 2
@giavac
giavac / parse_raw_opus.py
Created July 5, 2023 09:32
Get a raw opus file in, decode it into a wav file
#!/usr/bin/python3
import binascii
import opuslib
import wave
total_len = 0
def process_audio_data(audio_data, wav_file):
# print(binascii.hexlify(audio_data))
@giavac
giavac / decrypt_script.sh
Created July 4, 2023 15:42
Bash script to launch a decrypt program
#!/bin/bash
gcc decrypt.c -o decrypt -lssl -lz -lcrypto
encrypted="..."
tag="..."
iv="..."
key="..."
./decrypt "${encrypted}" "${tag}" "${iv}" "${key}"
@giavac
giavac / decrypt.c
Last active July 4, 2023 16:26
Decodes from base64, decrypts with key, tag and iv, then decompresses
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <zlib.h>
static char *base64_decode(const char *input, int length, int *output_length) {
BIO *bio, *b64;
@giavac
giavac / ACK_RFC3665
Created July 6, 2018 12:00
ACK as in RFC-3665
F15 ACK Alice -> Proxy 1
ACK sip:bob@client.biloxi.example.com SIP/2.0
Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74b76
Max-Forwards: 70
Route: <sip:ss1.atlanta.example.com;lr>,
<sip:ss2.biloxi.example.com;lr>
From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example.com>;tag=314159
Call-ID: 3848276298220188511@atlanta.example.com
[
{
"action": "conversation",
"name": "audio_delay_2",
"startOnEnter": true,
"record": true
}
]
@giavac
giavac / gist:3fd179ca579f695d8cf94b9ee82b58df
Created January 15, 2017 20:15
Lines to add to a sipp scenario to play RTP after ACK is received
<nop>
<action>
<exec play_pcap_audio="rtp_opus.pcap"/>
</action>
</nop>
#!/bin/bash
USERNAME=""
REALM=""
PASSWORD=""
METHOD="REGISTER"
DIGEST_URI=""
NONCE=""
EXPECTED=""