Skip to content

Commit 7e920dd

Browse files
committed
switch to poetry build system, set new version 1.0.0
1 parent a857836 commit 7e920dd

File tree

8 files changed

+93
-119
lines changed

8 files changed

+93
-119
lines changed

‎LICENSE‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎MANIFEST.in‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎pyproject.toml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[tool.poetry]
2+
name = "xortool"
3+
version = "1.0.0"
4+
description = "A tool to analyze multi-byte xor cipher"
5+
authors = ["hellman"]
6+
license = "MIT"
7+
readme = "README.md"
8+
keywords = ["xor", "xortool", "cryptanalysis"]
9+
classifiers = [
10+
'Intended Audience :: Information Technology',
11+
'Intended Audience :: Science/Research',
12+
'Topic :: Security :: Cryptography',
13+
]
14+
15+
[tool.poetry.scripts]
16+
xortool = 'xortool.tool_main:main'
17+
xortool-xor = 'xortool.tool_xor:main'
18+
19+
[tool.poetry.urls]
20+
homepage = "http://github.com/hellman/xortool"
21+
22+
[tool.poetry.dependencies]
23+
python = "^3.4"
24+
docopt = "^0.6.2"
25+
26+
[tool.poetry.dev-dependencies]
27+
docopt = "^0.6.2"
28+
29+
[build-system]
30+
requires = ["poetry-core>=1.0.0a5"]
31+
build-backend = "poetry.core.masonry.api"

‎setup.py‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎test/test.sh‎

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ set -epux -o pipefail
1111
shopt -s inherit_errexit
1212

1313
if [ $# -gt 0 ] && [ "dist" = "$1" ]; then
14-
export PATH="./xortool/:$PATH"
1514
export PYTHONPATH="."
15+
xortool="xortool/tool_main.py"
16+
xortool_xor="xortool/tool_xor.py"
17+
else
18+
xortool="xortool"
19+
xortool_xor="xortool-xor"
1620
fi
1721

1822
binary_xored_ok() {
@@ -27,49 +31,49 @@ binary_xored() {
2731
local f="$1"; shift
2832

2933
hexdump -Cv "$f" |cut -s -d' ' -f 3-20 | \
30-
xortool --hex -b
34+
$xortool --hex -b
3135
binary_xored_ok
3236

3337
hexdump -Cv "$f" |cut -s -d' ' -f 3-20 | \
34-
xortool -x -l 10 -c 00
38+
$xortool -x -l 10 -c 00
3539
binary_xored_ok
3640

3741
rm -rf xortool_out
38-
! xortool -x "$f"
42+
! $xortool -x "$f"
3943
[ ! -d xortool_out ]
4044

4145
rm -rf xortool_out
42-
! xortool --hex "$f"
46+
! $xortool --hex "$f"
4347
[ ! -d xortool_out ]
4448

45-
xortool -c 00 "$f"
49+
$xortool -c 00 "$f"
4650
binary_xored_ok
4751

48-
xortool --char=00 "$f"
52+
$xortool --char=00 "$f"
4953
binary_xored_ok
5054

51-
xortool -b "$f"
55+
$xortool -b "$f"
5256
binary_xored_ok
5357

54-
xortool -b -l 10 "$f"
58+
$xortool -b -l 10 "$f"
5559
binary_xored_ok
5660

57-
xortool --brute-chars --key-length=10 "$f"
61+
$xortool --brute-chars --key-length=10 "$f"
5862
binary_xored_ok
5963

60-
xortool -c 00 --key-length=10 "$f"
64+
$xortool -c 00 --key-length=10 "$f"
6165
binary_xored_ok
6266

63-
xortool -b --max-keylen=9 "$f"
67+
$xortool -b --max-keylen=9 "$f"
6468
! binary_xored_ok
6569

66-
xortool -b --key-length=16 "$f"
70+
$xortool -b --key-length=16 "$f"
6771
! binary_xored_ok
6872

69-
xortool -o "$f"
73+
$xortool -o "$f"
7074
! binary_xored_ok
7175

72-
xortool --brute-printable "$f"
76+
$xortool --brute-printable "$f"
7377
! binary_xored_ok
7478
}
7579

@@ -83,48 +87,48 @@ ls_xored() {
8387
local f="$1"; shift
8488

8589
hexdump -Cv "$f" |cut -s -d' ' -f 3-20 | \
86-
xortool --hex -b
90+
$xortool --hex -b
8791
ls_xored_ok
8892

8993
hexdump -Cv "$f" |cut -s -d' ' -f 3-20 | \
90-
xortool -x -l 33 -c 00
94+
$xortool -x -l 33 -c 00
9195
ls_xored_ok
9296

9397
rm -rf xortool_out
94-
! xortool -x "$f"
98+
! $xortool -x "$f"
9599
[ ! -d xortool_out ]
96100

97101
rm -rf xortool_out
98-
! xortool --hex "$f"
102+
! $xortool --hex "$f"
99103
[ ! -d xortool_out ]
100104

101-
xortool -c 00 "$f"
105+
$xortool -c 00 "$f"
102106
ls_xored_ok
103-
xortool --char=00 "$f"
107+
$xortool --char=00 "$f"
104108
ls_xored_ok
105109

106-
xortool -b "$f"
110+
$xortool -b "$f"
107111
ls_xored_ok
108112

109-
xortool -b -l 33 "$f"
113+
$xortool -b -l 33 "$f"
110114
ls_xored_ok
111115

112-
xortool --brute-chars --key-length=33 "$f"
116+
$xortool --brute-chars --key-length=33 "$f"
113117
ls_xored_ok
114118

115-
xortool -c 00 --key-length=33 "$f"
119+
$xortool -c 00 --key-length=33 "$f"
116120
ls_xored_ok
117121

118-
xortool -b --max-keylen=32 "$f"
122+
$xortool -b --max-keylen=32 "$f"
119123
! ls_xored_ok
120124

121-
xortool -b --key-length=35 "$f"
125+
$xortool -b --key-length=35 "$f"
122126
! ls_xored_ok
123127

124-
xortool -o "$f"
128+
$xortool -o "$f"
125129
! ls_xored_ok
126130

127-
xortool --brute-printable "$f"
131+
$xortool --brute-printable "$f"
128132
! ls_xored_ok
129133
}
130134

@@ -135,36 +139,36 @@ text_xored_ok() {
135139
}
136140

137141
text_xored() {
138-
xortool -o "$1"
142+
$xortool -o "$1"
139143
text_xored_ok
140144

141-
xortool -o -t printable "$1"
145+
$xortool -o -t printable "$1"
142146
text_xored_ok
143147

144-
xortool -o -t base32 "$1"
148+
$xortool -o -t base32 "$1"
145149
text_xored_ok
146150

147-
xortool -o -t base64 "$1"
151+
$xortool -o -t base64 "$1"
148152
text_xored_ok
149153

150-
xortool -o -t a "$1"
154+
$xortool -o -t a "$1"
151155
text_xored_ok
152156

153-
xortool -o -t A "$1"
157+
$xortool -o -t A "$1"
154158
text_xored_ok
155159

156-
xortool -o -t 1 "$1"
160+
$xortool -o -t 1 "$1"
157161
text_xored_ok
158162

159-
xortool -o -t '!' "$1"
163+
$xortool -o -t '!' "$1"
160164
text_xored_ok
161165

162-
xortool -o -t '*' "$1"
166+
$xortool -o -t '*' "$1"
163167
text_xored_ok
164168

165-
! xortool -o -t Z "$1"
169+
! $xortool -o -t Z "$1"
166170

167-
xortool -o -t '' "$1"
171+
$xortool -o -t '' "$1"
168172
text_xored_ok
169173
}
170174

@@ -175,7 +179,7 @@ tool_xored_ok() {
175179
}
176180

177181
tool_xored() {
178-
xortool -o "$1"
182+
$xortool -o "$1"
179183
tool_xored_ok
180184
}
181185

@@ -184,16 +188,16 @@ ls_xored test/data/ls_xored
184188
text_xored test/data/text_xored
185189
tool_xored test/data/tool_xored
186190

187-
[ "$(./xortool/xortool-xor -n -s '\x3012345' -r 'A' | ./xortool/xortool-xor -r 'A' -f-)" = "012345" ]
188-
[ "$(./xortool/xortool-xor -n -s '\x3012345' -r 'A')" = "qpsrut" ]
189-
[ "$(./xortool/xortool-xor -n -h '30 31 32 33 34 35 ' -r 'A' | ./xortool/xortool-xor -r 'A' -f-)" = "012345" ]
190-
[ "$(./xortool/xortool-xor -n -r qpsrut -r 'A')" = "012345" ]
191+
[ "$($xortool_xor -n -s '\x3012345' -r 'A' | $xortool_xor -r 'A' -f-)" = "012345" ]
192+
[ "$($xortool_xor -n -s '\x3012345' -r 'A')" = "qpsrut" ]
193+
[ "$($xortool_xor -n -h '30 31 32 33 34 35 ' -r 'A' | $xortool_xor -r 'A' -f-)" = "012345" ]
194+
[ "$($xortool_xor -n -r qpsrut -r 'A')" = "012345" ]
191195

192-
xortool -c 00 --key-length=10 test/data/binary_xored
196+
$xortool -c 00 --key-length=10 test/data/binary_xored
193197
f_cmp="$(grep 'secret_key' xortool_out/filename-key.csv|cut -d\; -f1)"
194-
xortool-xor -n -r secret_key -f "$f_cmp" | \
198+
$xortool_xor -n -r secret_key -f "$f_cmp" | \
195199
cmp test/data/binary_xored
196-
xortool-xor -n -r secret_key -f test/data/binary_xored | \
200+
$xortool_xor -n -r secret_key -f test/data/binary_xored | \
197201
cmp "$f_cmp"
198202

199203
echo OK

‎xortool/__init__.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
__all__ = "args", "colors", "libcolors", "routine"
2-
__version__ = "0.99"
1+
from importlib_metadata import version
2+
3+
__version__ = version(__package__)

‎xortool/xortool‎ renamed to ‎xortool/tool_main.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
2-
"""
3-
xortool
2+
from xortool import __version__
3+
__doc__ = f"""
4+
xortool {__version__}
45
A tool to do some xor analysis:
56
- guess the key length (based on count of equal chars)
67
- guess the key (base on knowledge of most frequent char)
@@ -46,7 +47,6 @@
4647
import string
4748
import sys
4849

49-
import xortool
5050
from xortool.args import (
5151
parse_parameters,
5252
ArgError,
@@ -82,7 +82,7 @@ class AnalysisError(Exception):
8282

8383
def main():
8484
try:
85-
PARAMETERS.update(parse_parameters(__doc__, xortool.__version__))
85+
PARAMETERS.update(parse_parameters(__doc__, __version__))
8686
ciphertext = get_ciphertext()
8787
if not PARAMETERS["known_key_length"]:
8888
PARAMETERS["known_key_length"] = guess_key_length(ciphertext)

‎xortool/xortool-xor‎ renamed to ‎xortool/tool_xor.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
2-
#-*- coding:utf-8 -*-
3-
4-
"""
2+
from xortool import __version__
3+
__doc__ = f"""
4+
xortool-xor {__version__}
55
xor strings
66
options:
77
-s - string with \\xAF escapes
@@ -14,12 +14,9 @@
1414
--cycle - do not pad (default)
1515
--no-cycle / --nc - pad smaller strings with null bytes
1616
example: xor -s lol -h 414243 -f /etc/passwd
17-
18-
author: hellman ( hellman1908@gmail.com )
1917
"""
2018

2119
import getopt
22-
import string
2320
import sys
2421

2522

0 commit comments

Comments
 (0)