MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / test_feed_full_client_session

Function test_feed_full_client_session

tests/test_irc_dpi.py:56–81  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

54
55
56def test_feed_full_client_session(parser):
57 bot_ip = '192.168.1.73'
58 c2_ip = '203.0.113.10'
59 c_port, s_port = 54321, 6667
60
61 _feed(parser, bot_ip, c2_ip, c_port, s_port, 1.0,
62 "NICK bot01\r\nUSER bot01 0 * :bot01\r\n")
63 _feed(parser, bot_ip, c2_ip, c_port, s_port, 2.0,
64 "JOIN #control\r\n")
65 _feed(parser, c2_ip, bot_ip, s_port, c_port, 2.5,
66 ":server.example 001 bot01 :Welcome to the IRC Network\r\n"
67 ":operator!op@host PRIVMSG #control :!exec whoami\r\n")
68 _feed(parser, bot_ip, c2_ip, c_port, s_port, 3.0,
69 "PRIVMSG #control :root\r\n")
70
71 sessions = parser.get_sessions()
72 assert len(sessions) == 1
73 s = sessions[0]
74 assert s['client_ip'] == bot_ip
75 assert s['server_ip'] == c2_ip
76 assert s['server_port'] == s_port
77 assert s['nick'] == 'bot01'
78 assert s['user'] == 'bot01'
79 assert '#control' in s['channels']
80 assert s['cmd_counts'].get('PRIVMSG') == 2
81 assert any('Welcome' in b for b in s['server_banner'])
82
83
84def test_feed_handles_partial_frames(parser):

Callers

nothing calls this directly

Calls 3

_feedFunction · 0.85
get_sessionsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected