1221
* \test DetectAsn1TestReal04 like the real test 02, but modified the
1222
* relative offset to check negative offset values, in this case
1223
* start decoding from -7 bytes respect the content match "John"
1225
int DetectAsn1TestReal04(void) {
1227
uint8_t *buf = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01"
1228
"P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director"
1229
"\x42\x01\x33\xA1\x0A\x43\x08""19710917"
1230
"\xA2\x12\x61\x10\x1A\x04""Mary""\x1A\x01""T""\x1A\x05"
1231
"Smith""\xA3\x42\x31\x1F\x61\x11\x1A\x05""Ralph""\x1A\x01"
1232
"T""\x1A\x05""Smith""\xA0\x0A\x43\x08""19571111"
1233
"\x31\x1F\x61\x11\x1A\x05""Susan""\x1A\x01""B""\x1A\x05"
1234
"Jones""\xA0\x0A\x43\x08""19590717"
1235
"\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01""P"
1236
"\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director"
1237
"\x42\x01\x33\xA1\x0A\x43\x08""19710917"
1238
"\xA2\x12\x61\x10\x1A\x04""Mary""\x1A\x01""T""\x1A\x05"
1239
"Smith""\xA3\x42\x31\x1F\x61\x11\x1A\x05""Ralph""\x1A\x01"
1240
"T""\x1A\x05""Smith""\xA0\x0A\x43\x08""19571111""\x31\x1F"
1241
"\x61\x11\x1A\x05""Pablo""\x1A\x01""B""\x1A\x05""Jones"
1242
"\xA0\x0A\x43\x08""19590717";
1244
uint16_t buflen = strlen((char *)buf) - 1;
1246
/* Check the start with AA (this is to test the relative_offset keyword) */
1247
uint8_t *buf2 = (uint8_t *) "AA\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01"
1248
"P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director"
1249
"\x42\x01\x33\xA1\x0A\x43\x08""19710917"
1250
"\xA2\x12\x61\x10\x1A\x04""Mary""\x1A\x01""T""\x1A\x05"
1251
"Smith""\xA3\x42\x31\x1F\x61\x11\x1A\x05""Ralph""\x1A\x01"
1252
"T""\x1A\x05""Smith""\xA0\x0A\x43\x08""19571111"
1253
"\x31\x1F\x61\x11\x1A\x05""Susan""\x1A\x01""B""\x1A\x05"
1254
"Jones""\xA0\x0A\x43\x08""19590717"
1255
"\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01""P"
1256
"\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director"
1257
"\x42\x01\x33\xA1\x0A\x43\x08""19710917"
1258
"\xA2\x12\x61\x10\x1A\x04""Mary""\x1A\x01""T""\x1A\x05"
1259
"Smith""\xA3\x42\x31\x1F\x61\x11\x1A\x05""Ralph""\x1A\x01"
1260
"T""\x1A\x05""Smith""\xA0\x0A\x43\x08""19571111""\x31\x1F"
1261
"\x61\x11\x1A\x05""Susan""\x1A\x01""B""\x1A\x05""Jones"
1262
"\xA0\x0A\x43\x08""19590717";
1264
uint16_t buflen2 = strlen((char *)buf2) - 1;
1268
p[0] = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP);
1269
p[1] = UTHBuildPacket((uint8_t *)buf2, buflen2, IPPROTO_TCP);
1271
if (p[0] == NULL || p[1] == NULL)
1275
sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; "
1276
"content:\"Pablo\"; asn1:absolute_offset 0, "
1277
"oversize_length 140; sid:1;)";
1278
sigs[1]= "alert ip any any -> any any (msg:\"Testing id 2\"; "
1279
"content:\"John\"; asn1:relative_offset -7, "
1280
"oversize_length 140; sid:2;)";
1281
sigs[2]= "alert ip any any -> any any (msg:\"Testing id 3\"; "
1282
"content:\"lalala\"; asn1: oversize_length 2000; sid:3;)";
1284
uint32_t sid[3] = {1, 2, 3};
1286
uint32_t results[2][3] = {
1289
/* None of the packets should match */
1291
result = UTHGenericTest(p, 2, sigs, sid, (uint32_t *) results, 3);
1293
UTHFreePackets(p, 2);
1220
1298
#endif /* UNITTESTS */