2023-06-22 00:06:53 +01:00
|
|
|
#!/usr/bin/env python3
|
2017-01-11 01:54:00 +03:00
|
|
|
|
|
|
|
import sys, os
|
|
|
|
import hashlib
|
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
|
|
|
|
str2 = "test_test" * (1 << 20)
|
|
|
|
str1 = "Test_Test!"
|
|
|
|
|
|
|
|
src = os.getenv("TCP_SRC", "127.0.0.1")
|
|
|
|
dst = os.getenv("TCP_DST", "127.0.0.1")
|
|
|
|
sport = os.getenv("TCP_SPORT", "12345")
|
|
|
|
dport = os.getenv("TCP_DPORT", "54321")
|
|
|
|
|
2018-09-23 15:31:52 +01:00
|
|
|
print(sys.argv[1])
|
2019-09-07 15:46:22 +03:00
|
|
|
args = [
|
|
|
|
sys.argv[1], "--addr", src, "--port", sport, "--seq", "555", "--next",
|
|
|
|
"--addr", dst, "--port", dport, "--seq", "666", "--reverse", "--",
|
|
|
|
"./tcp-test.py"
|
|
|
|
]
|
2017-01-11 01:54:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
p1 = Popen(args + ["dst"], stdout=PIPE, stdin=PIPE)
|
2017-01-11 01:54:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
args.remove("--reverse")
|
2017-01-11 01:54:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
p2 = Popen(args + ["src"], stdout=PIPE, stdin=PIPE)
|
2017-01-11 01:54:00 +03:00
|
|
|
|
|
|
|
p1.stdout.read(5)
|
|
|
|
p2.stdout.read(5)
|
|
|
|
p1.stdin.write("start")
|
|
|
|
p2.stdin.write("start")
|
|
|
|
|
|
|
|
p1.stdin.write(str1)
|
|
|
|
p1.stdin.close()
|
|
|
|
p2.stdin.write(str2)
|
|
|
|
p2.stdin.close()
|
|
|
|
|
|
|
|
s = p1.stdout.read()
|
|
|
|
m = hashlib.md5()
|
|
|
|
m.update(str2)
|
|
|
|
str2 = m.hexdigest()
|
|
|
|
|
|
|
|
if str2 != eval(s):
|
2018-09-23 15:31:52 +01:00
|
|
|
print("FAIL", repr(str2), repr(s))
|
2019-09-07 15:46:22 +03:00
|
|
|
sys.exit(5)
|
2017-01-11 01:54:00 +03:00
|
|
|
|
|
|
|
s = p1.stdout.read()
|
|
|
|
m = hashlib.md5()
|
|
|
|
m.update(str1)
|
|
|
|
str1 = m.hexdigest()
|
|
|
|
|
|
|
|
s = p2.stdout.read()
|
|
|
|
if str1 != eval(s):
|
2018-09-23 15:31:52 +01:00
|
|
|
print("FAIL", repr(str1), s)
|
2019-09-07 15:46:22 +03:00
|
|
|
sys.exit(5)
|
2017-01-11 01:54:00 +03:00
|
|
|
|
|
|
|
if p1.wait():
|
|
|
|
sys.exit(1)
|
|
|
|
if p2.wait():
|
|
|
|
sys.exit(1)
|
|
|
|
|
2018-09-23 15:31:52 +01:00
|
|
|
print("PASS")
|