-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplunkDataGeneratorTCP.py
More file actions
55 lines (42 loc) · 2.34 KB
/
Copy pathsplunkDataGeneratorTCP.py
File metadata and controls
55 lines (42 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import random
import socket
import json
import time
from datetime import datetime
def commitCrime():
# list of sample values
suspect = ['Miss Scarett','Professor Plum','Miss Peacock','Mr. Green','Colonel Mustard','Mrs. White', 'Mr. Red', 'Mr. Gates', 'Young Peter', 'Young Claire', 'Grandpa Ray', 'Grandma Shonda', 'Nurse Ane']
weapons = ['candlestick','knife','lead pipe','revolver','rope','wrench','baseball bat', 'punch', 'harmonica','sword', 'rock']
actions = ['success','attempt','fail','canceled','arrested','contained']
crime_types = ['single','multiple','violent','property','organized','white-collar']
victims = ['John Lister','Ama Holly','Paul Lence','Jessica Mon','Billy Horn','Shonda MCals','Michael Anothony','Geff Gutemberg','Alonso Aguiar','Hugo Martinez']
rooms = ['kitchen','ballroom','conservatory','dining room','cellar','billiard room','library','lounge','hall','study','swimming pool', 'living room', 'basement', 'garage','game room']
periods_day = ['afternoon','bedtime','dinnertime','lunchtime','morning','dawn']
curr_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
return {"timestamp":curr_time,"suspect":random.choice(suspect), "weapon":random.choice(weapons), "location":random.choice(rooms), "period of the day":random.choice(periods_day), "victim":random.choice(victims), "crime_type":random.choice(crime_types), "action":random.choice(actions)}
def main():
crimeCounter = 1
host = '129.159.58.78' # <--! Set Splunk Log Collector IP here !-->
port = 10000# <--! Set Port here !-->
while True:
try:
# SOCKET CREATION
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# SOCKET CONNECTION
sock.connect((host,port))
# EVENT CREATION
event = commitCrime()
event.update({"crime_number":crimeCounter})
# PACKET CREATION
message = json.dumps(event)
# PACKET SENDER
sock.send(bytes(message, encoding="utf-8"))
# CRIME COUNTER (FOR THE LOG)
crimeCounter += 1
# TIME WAIT TO SIMULATE REAL LOG BEHAVIOR
time.sleep(.3)
# SOCKET CLOSE
finally:
sock.close()
if __name__ == '__main__':
main()