-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathHoneyDoc.py
executable file
·114 lines (99 loc) · 3.33 KB
/
HoneyDoc.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
#Honey Document Generator v1.0.3
#Copyright (C)2018 Jacob Parks - jqreator at gmail dot com
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#Release notes:
#v1.0.0 - Initial release
#v1.0.1 - Made beacon an option instead of the default and removed unused options
#v1.0.2 - Updated img tag to use better form
#v1.0.3 - Bug fix to close the table tag properly when not using a beacon image, minor formatting improvements, and removed the deprecated center tag
import argparse
import random
import sys
#Set default document values
docTitle = "Employee Information" #Title of document
numRec = 10 #Number of records to create
imgURL = "http://127.0.0.1/hello.png" #URL of tracking image
fileExt = "doc" #Default file extension
#Declare variables
n = 0
tRow = ""
#Import name list
with open("names.txt") as nameDoc:
nameList = nameDoc.read().splitlines()
listLen = len(nameList)
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--title", help="Specify a custom document title. Default is " + docTitle)
parser.add_argument("-c", "--count", help="Number of fake records to create. Default is " + str(numRec))
parser.add_argument("-b", "--beacon", help="Include a beacon image. Default is " + imgURL, action="store_true")
parser.add_argument("-u", "--url", help="Set a custom URL for the beacon image.")
parser.add_argument("-e", "--ext", help="File extension. Default is " + fileExt)
args = parser.parse_args()
if args.title:
docTitle = args.title
if args.count:
numRec = int(args.count)
if args.url:
imgURL = args.url
if args.ext:
fileExt = args.ext
#Generate a random fake SSN
def getSSN():
num1 = random.randint(100,999)
num2 = random.randint(10,99)
num3 = random.randint(1000,9999)
return str(num1) + "-" + str(num2) + "-" + str(num3)
#Generate a random name
def getName():
fNameNum = random.randint(0,listLen - 1)
lNameNum = random.randint(0,listLen - 1)
return nameList[fNameNum] + " " + nameList[lNameNum]
#Create table rows
while n < numRec:
ss = getSSN()
name = getName()
tRow = tRow + "<tr><td width=200>" + name + "</td><td>" + ss + "</td></tr>"
n = n + 1
#Build HTML sections
html1 = """
<html>
<body>
<p><font size="6"><b>
"""
html2 = """
</b></font></p>
<table style="width:100%">
<tr>
<th align="left">Name</th>
<th align="left">Social Security</th>
"""
html3 = """
</table>
"""
html4 = """
</body>
</html>
"""
imgTag = '<img src="' + imgURL + '" width="1" height="1" border="0"/>'
#Build file contents with beacon included
if args.beacon == True:
toWrite = html1 + docTitle + html2 + tRow + html3 + imgTag + html4
else:
toWrite = html1 + docTitle + html2 + tRow + html3 + html4
#Write the file
f = open("honeydoc." + fileExt,"w")
f.write(toWrite)
f.close()