Skip to content

Commit 04d08aa

Browse files
authored
Merge pull request #5 from adobe/dev.jwt
Dev.jwt
2 parents 0d4626d + 3813bda commit 04d08aa

File tree

7 files changed

+20
-2
lines changed

7 files changed

+20
-2
lines changed

data/enhanced-c.bestType

2.01 MB
Binary file not shown.

data/enhanced-c.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"char_emb_size": 100, "rnn_layers": 2, "rnn_size": 100, "hidden": 500}

data/enhanced-c.encodings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"char2int": {"<PAD>": 0, "<UNK>": 1, "p": 2, "e": 3, "h": 4, "r": 5, "d": 6, "o": 7, "|": 8, "b": 9, "u": 10, "n": 11, "s": 12, " ": 13, "!": 14, "l": 15, "a": 16, "w": 17, "c": 18, "i": 19, "f": 20, "2": 21, "1": 22, "7": 23, "{": 24, "y": 25, "j": 26, "0": 27, "x": 28, "k": 29, "v": 30, "q": 31, "g": 32, "z": 33, "9": 34, ".": 35, "6": 36, "m": 37, "5": 38, "3": 39, "t": 40, "4": 41, "-": 42, "}": 43, "&": 44, "=": 45, ":": 46, ",": 47, "8": 48, "\\": 49, "'": 50, "(": 51, ")": 52, "%": 53, "@": 54, "$": 55, "\"": 56, ";": 57, "[": 58, "]": 59, "`": 60, "_": 61, "<": 62, "~": 63, "/": 64, "+": 65, "#": 66, "?": 67, "*": 68, ">": 69}, "label2int": {"<PAD>": 0, "C": 1, "J": 2, "N": 3, "H": 4, "U": 5, "I": 6}}

data/enhanced-c.last

2.01 MB
Binary file not shown.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def parse_requirements(filename, session=None):
1212

1313
setuptools.setup(
1414
name="stringlifier",
15-
version="0.1.0.8",
15+
version="0.1.0.9",
1616
author="Multiple authors",
1717
author_email="tiberiu44@gmail.com",
1818
description="Python module for detecting password, api keys hashes and any other string that resembles a randomly generated character sequence.",

stringlifier/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ def _extract_tokens(self, string: str, pred: NDArray[Int64]) -> Tuple[str, List[
226226
type_ = '<IP_ADDR>'
227227
elif last_label == 'U':
228228
type_ = '<UUID>'
229+
elif last_label == 'J':
230+
type_ = '<JWT>'
229231
if last_label != 'C':
230232
tokens.append((c_tok, start, ii, type_))
231233

stringlifier/modules/training.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
known_words = []
1818

1919

20+
2021
def _generate_word(known_words):
2122
import uuid
2223
import datetime
2324
import base64
2425
generated = None
25-
ii = random.randint(0, 4)
26+
ii = random.randint(0, 5)
2627
mask = 'H'
2728
if ii == 0:
2829
generated = str(uuid.uuid4())
@@ -61,13 +62,26 @@ def _generate_word(known_words):
6162
toks.append(str(random.randint(0, 255)))
6263
generated = '.'.join(toks)
6364
mask = 'I'
65+
elif ii==5:
66+
generated=_generate_JWT_token(known_words)
67+
mask = 'J'
6468
return str(generated), mask[0]
6569

6670

6771
lines = open('corpus/words_alpha.txt').readlines()
6872
for line in lines:
6973
known_words.append(line.strip())
7074

75+
76+
def _generate_JWT_token(known_words):
77+
import jwt
78+
79+
payload = {"id": str(random.random()), "client_id": str(random.random()), "user_id": str(random.random()), "type": "access_token",
80+
"expires_in": str(random.randint(10,3600000)), "scope": "read, write", "created_at": str(random.randint(1900000, 9000000))}
81+
encoded_jwt = jwt.encode(payload, 'secret', algorithm='HS256')
82+
83+
return str(encoded_jwt)[2:-1]
84+
7185
# generated_words = generate_words(len(known_words), known_words)
7286

7387
known_index = 0

0 commit comments

Comments
 (0)