-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from sipcapture/dev
Dev
- Loading branch information
Showing
142 changed files
with
1,114 additions
and
2,601 deletions.
There are no files selected for viewing
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
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
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
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
### You need to install indent | ||
echo "indent file $1..." | ||
indent -linux -l200 -i4 -nut "$1" | ||
echo "format done" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
#mkdir -p work | ||
#cd work | ||
#rm -rf captagent | ||
#cp ../src/captagent.zip . | ||
#unzip -P 'XXX' captagent.zip | ||
#rm captagent.zip | ||
cd ../../ | ||
./build.sh | ||
|
||
export CFLAGS="-g -O0 -fsanitize=address -fprofile-instr-generate -fcoverage-mapping" | ||
export CC="clang" | ||
CC=clang CFLAGS="-g -O0 -fsanitize=address -fprofile-instr-generate -fcoverage-mapping" ./configure \ | ||
--enable-tls --enable-ssl | ||
|
||
find . -type f -print0 | xargs -0 sed -i 's/static volatile/static volatile/g' | ||
|
||
make CFLAGS="-g -O0 -fsanitize=address -fprofile-instr-generate -fcoverage-mapping" | ||
|
||
#export DESTDIR="`pwd`/debug-build" | ||
make install |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p work | ||
cd work | ||
rm -rf captagent | ||
cp ../src/captagent.zip . | ||
unzip -P 'XXX' captagent.zip | ||
rm captagent.zip | ||
cd captagent | ||
./build.sh | ||
|
||
export CFLAGS="-g -O0 -fprofile-instr-generate -fcoverage-mapping" | ||
export CC="clang" | ||
CC=clang CFLAGS="-g -O0 -fprofile-instr-generate -fcoverage-mapping" ./configure \ | ||
--enable-tls --enable-ssl | ||
|
||
find . -type f -print0 | xargs -0 sed -i 's/static volatile/static volatile/g' | ||
|
||
make CFLAGS="-g -O0 -fprofile-instr-generate -fcoverage-mapping" | ||
|
||
export DESTDIR="`pwd`/debug-build" | ||
make install |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p work | ||
cd work | ||
rm -rf captagent | ||
cp ../src/captagent.zip . | ||
unzip -P 'XXX' captagent.zip | ||
cd captagent | ||
./build.sh | ||
./configure --enable-ssl --enable-tls | ||
make | ||
|
||
export DESTDIR="`pwd`/debug-build" | ||
make install |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
CAPTAGENT="../../../../captagent" | ||
|
||
clang -fsanitize=address \ | ||
-o $CAPTAGENT/test/fuzzing/fuzz_test/RTCP_CRASH/rtcp_crash \ | ||
-g -O0 -w -I$CAPAGENT/include \ | ||
-I$CAPTAGENT/src \ | ||
-I$CAPTAGENT/src/modules/protocol/rtcp \ | ||
`find $CAPTAGENT/src/ -maxdepth 1 -name "*.c" ! -name 'captagent.c'` \ | ||
`find $CAPTAGENT/src/modules/protocol/rtcp -maxdepth 1 -name "*.c"` \ | ||
-ljson-c -lpcap -lexpat -ldl -lpthread -lfl -luv -lm -lcrypto -lpcre |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <captagent/api.h> | ||
#include <captagent/proto_sip.h> | ||
#include <captagent/structure.h> | ||
#include <captagent/capture.h> | ||
#include <captagent/xmlread.h> | ||
#include <captagent/modules_api.h> | ||
#include <captagent/modules.h> | ||
#include <captagent/log.h> | ||
#include <dirent.h> | ||
#include "md5.h" | ||
#include <captagent/globals.h> | ||
#include "captagent.h" | ||
#include "config.h" | ||
#include "modules/protocol/rtcp/parser_rtcp.h" | ||
|
||
int cfg_errors = 0; | ||
int debug = 0; | ||
struct capture_list main_ct; | ||
char *module_name_p = ""; | ||
char *global_node_name = NULL; | ||
char *global_config_path = NULL; | ||
int print_lic_exit = 0; | ||
char *global_license = NULL; | ||
int not_send = 0; | ||
int flag_Lic = -1; // License: 1 = activate; 0 = deactivate | ||
int type_Lic = 1; | ||
int count_big_down_jump = 0; | ||
char *usefile = NULL; | ||
unsigned long expireLicTime = 0; | ||
int flag_is_lic_count_wrong = 0; | ||
char hwk[33]; | ||
int flag_is_expire = 0; | ||
int flag_is_invalid = 0; | ||
int bytes_parsed = 0; | ||
|
||
int main() | ||
{ | ||
/* MALFORMED RTCP RR PKT */ | ||
// Correct pkt is 4 byte header + 4 bytes SSRC + 24 byte for every Report count (if exist) | ||
// in this case count == 1 (first byte 0x81) | ||
char rr[29] = { | ||
0x81, 0xc9, 0x00, 0x07, 0x54, 0xf2, 0x00, 0x01, | ||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x81, | ||
0xc9, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, | ||
}; | ||
|
||
/* MALFORMED RTCP SR PKT */ | ||
// Correct pkt is 4 byte header + 4 byte SSRC + 20 byte for sender info + 24 byte for every Report count (if exist) | ||
char sr[25] = { | ||
0x80, 0xc8, 0x00, 0x06, 0x22, 0xa1, 0x04, 0x02, | ||
0x83, 0xab, 0x11, 0x03, 0xeb, 0x00, 0x01, 0x3a, | ||
0x00, 0x00, 0x94, 0x20, 0x00, 0x00, 0x00, 0xfb, | ||
0x10, | ||
}; | ||
|
||
|
||
char *json_rtcp_buffer; | ||
int ret, len; | ||
|
||
len = sizeof(sr); | ||
json_rtcp_buffer = calloc(5000, sizeof(char)); | ||
ret = capt_parse_rtcp(&sr, len, json_rtcp_buffer, 5000); | ||
if(ret == -1 || ret == -2) { | ||
printf("capt_parse_rtcp :: error!\n"); | ||
} else { | ||
printf("capt_parse_rtcp :: parsing correct\n"); | ||
} | ||
if(json_rtcp_buffer) free(json_rtcp_buffer); | ||
|
||
printf("!!! IF WE ARE HERE NO CRASH DETECTED IN MEMORY !!!") | ||
return 0; | ||
} |
17 changes: 17 additions & 0 deletions
17
fuzzing/fuzz_test/RTCP_TO_JSON_CRASH/rtcp_capture_plan.cfg
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
capture[pcap] { | ||
if(msg_check("size","4")) { | ||
if(is_rtcp_or_rtp()) { | ||
if(is_flag_set("1","1")) { | ||
drop; | ||
} else { | ||
parse_rtcp_to_json(); | ||
check_rtcp_session("hep","rtpsocket"); | ||
drop; | ||
} | ||
drop; | ||
} | ||
drop; | ||
} | ||
drop; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import( | ||
"net" | ||
) | ||
|
||
func main() { | ||
dat := []byte{ | ||
0x81,0xc9,0x00,0x07,0x00,0x00,0x00,0x01,0x00, | ||
0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x00,0x00,0x00} | ||
|
||
conn, _ := net.Dial("udp","127.0.0.1:9000") | ||
|
||
for i := 1; i < 50; i++ { | ||
conn.Write(dat) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
rm -f *.profraw | ||
rm -f *.profdata | ||
|
||
coverage="coverage/" | ||
if [ "$2" != "" ]; then | ||
coverage="$2" | ||
fi | ||
|
||
rm -rf $coverage | ||
mkdir -p $coverage | ||
mkdir -p $coverage/line | ||
mkdir -p $coverage/source | ||
mkdir -p $coverage/functions | ||
LLVM_PROFILE_FILE="prof%p.profraw" \ | ||
work/captagent/debug-build/usr/local/captagent/sbin/captagent \ | ||
-f captagent-config/$1/captagent.xml | ||
llvm-profdata merge -sparse *.profraw -o captagent.profdata | ||
|
||
llvm-cov show work/captagent/debug-build/usr/local/captagent/sbin/captagent -instr-profile=captagent.profdata > $coverage/line/captagent-lines.txt | ||
for f in work/captagent/debug-build/usr/local/captagent/lib/captpagent/modules/*.so; | ||
do | ||
llvm-cov show $f -instr-profile=captagent.profdata > $coverage/line/`basename $f`-lines.txt | ||
done | ||
|
||
llvm-cov report work/captagent/debug-build/usr/local/captagent/sbin/captagent -instr-profile=captagent.profdata > $coverage/source/captagent-source.txt | ||
for f in work/captagent/debug-build/usr/local/captagent/lib/captagent/modules/*.so; | ||
do | ||
llvm-cov report $f -instr-profile=captagent.profdata > $coverage/source/`basename $f`-source.txt | ||
done | ||
|
||
llvm-cov report work/captagent/debug-build/usr/local/captagent/sbin/captagent -show-functions=true --instr-profile=captagent.profdata work/captagent | ||
for f in work/captagent/debug-build/usr/local/captagent/lib/captagent/modules/*.so; | ||
do | ||
llvm-cov report $f -show-functions=true -instr-profile=captagent.profdata work/captagent/ > $coverage/functions/`basename $f`-functions.txt | ||
done | ||
|
||
# rm -f *.profraw *.profdata | ||
chown root.root coverage | ||
chown root.root $coverage/* |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
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
Oops, something went wrong.