text-deobfuscate 0.1.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. text_deobfuscate/__init__.py +13 -0
  2. text_deobfuscate/__main__.py +5 -0
  3. text_deobfuscate/cli.py +30 -0
  4. text_deobfuscate/core.py +21 -0
  5. text_deobfuscate/data/NOTICE.md +10 -0
  6. text_deobfuscate/data/SCOWL-COPYRIGHT.txt +248 -0
  7. text_deobfuscate/data/lookalikes.txt +597 -0
  8. text_deobfuscate/data/ngrams.txt +33813 -0
  9. text_deobfuscate/data/scripts.txt +999 -0
  10. text_deobfuscate/data/words.txt +92459 -0
  11. text_deobfuscate/engine.py +196 -0
  12. text_deobfuscate/protect.py +42 -0
  13. text_deobfuscate/py.typed +0 -0
  14. text_deobfuscate/resources.py +39 -0
  15. text_deobfuscate/scorer.py +90 -0
  16. text_deobfuscate/scripts.py +23 -0
  17. text_deobfuscate/transforms/__init__.py +57 -0
  18. text_deobfuscate/transforms/base.py +52 -0
  19. text_deobfuscate/transforms/base64.py +61 -0
  20. text_deobfuscate/transforms/bytes.py +58 -0
  21. text_deobfuscate/transforms/caesar.py +203 -0
  22. text_deobfuscate/transforms/emoji.py +59 -0
  23. text_deobfuscate/transforms/escapes.py +121 -0
  24. text_deobfuscate/transforms/invisible.py +70 -0
  25. text_deobfuscate/transforms/leet.py +415 -0
  26. text_deobfuscate/transforms/lookalike.py +298 -0
  27. text_deobfuscate/transforms/mail.py +107 -0
  28. text_deobfuscate/transforms/marks.py +87 -0
  29. text_deobfuscate/transforms/misspelling.py +113 -0
  30. text_deobfuscate/transforms/morse.py +87 -0
  31. text_deobfuscate/transforms/repeated.py +73 -0
  32. text_deobfuscate/transforms/reverse.py +127 -0
  33. text_deobfuscate/transforms/runs.py +55 -0
  34. text_deobfuscate/transforms/separator.py +145 -0
  35. text_deobfuscate/transforms/shorthand.py +99 -0
  36. text_deobfuscate/transforms/styled.py +90 -0
  37. text_deobfuscate/types.py +33 -0
  38. text_deobfuscate-0.1.0a1.dist-info/METADATA +257 -0
  39. text_deobfuscate-0.1.0a1.dist-info/RECORD +42 -0
  40. text_deobfuscate-0.1.0a1.dist-info/WHEEL +4 -0
  41. text_deobfuscate-0.1.0a1.dist-info/entry_points.txt +3 -0
  42. text_deobfuscate-0.1.0a1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,13 @@
1
+ """Undo text obfuscation and report which transforms were applied."""
2
+
3
+ from importlib import metadata as _metadata
4
+
5
+ from text_deobfuscate.core import STRICTNESS_LEVELS, deobfuscate
6
+ from text_deobfuscate.types import Result, Step
7
+
8
+ try:
9
+ __version__ = _metadata.version("text-deobfuscate")
10
+ except _metadata.PackageNotFoundError: # running from a source tree that was never installed
11
+ __version__ = "unknown"
12
+
13
+ __all__ = ["STRICTNESS_LEVELS", "Result", "Step", "__version__", "deobfuscate"]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from text_deobfuscate.cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,30 @@
1
+ import argparse
2
+ import json
3
+ import sys
4
+
5
+ from text_deobfuscate import __version__
6
+ from text_deobfuscate.core import STRICTNESS_LEVELS, deobfuscate
7
+
8
+
9
+ def main(argv: list[str] | None = None) -> int:
10
+ parser = argparse.ArgumentParser(
11
+ prog="text-deobfuscate",
12
+ description="Undo text obfuscation. Reads the text argument, or standard input if none is given.",
13
+ )
14
+ parser.add_argument("text", nargs="?", help="text to deobfuscate; standard input if omitted")
15
+ parser.add_argument("--strictness", choices=STRICTNESS_LEVELS, default="conservative")
16
+ parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
17
+ parser.add_argument("--json", action="store_true", help="print the text and the steps applied as JSON")
18
+ args = parser.parse_args(argv)
19
+
20
+ text = args.text if args.text is not None else sys.stdin.read()
21
+ result = deobfuscate(text, strictness=args.strictness)
22
+ if args.json:
23
+ json.dump(result.to_dict(), sys.stdout, ensure_ascii=False)
24
+ sys.stdout.write("\n")
25
+ else:
26
+ # Nothing is added when the output is piped or redirected: the contract is the
27
+ # text and only the text, so `text-deobfuscate x > file` writes exactly that. A
28
+ # terminal gets a line ending, or the shell prompt lands mid-text.
29
+ sys.stdout.write(result.text + "\n" if sys.stdout.isatty() else result.text)
30
+ return 0
@@ -0,0 +1,21 @@
1
+ from text_deobfuscate.engine import LEVELS, Engine
2
+ from text_deobfuscate.types import Result
3
+
4
+ STRICTNESS_LEVELS = LEVELS
5
+
6
+
7
+ def deobfuscate(text: str, *, strictness: str = "conservative", raise_errors: bool = False) -> Result:
8
+ """Return ``text`` with obfuscation undone, plus the steps applied.
9
+
10
+ If anything goes wrong internally the text is returned unchanged, unless
11
+ ``raise_errors`` is set.
12
+ """
13
+ if strictness not in STRICTNESS_LEVELS:
14
+ raise ValueError(f"strictness must be one of {STRICTNESS_LEVELS}, got {strictness!r}")
15
+ try:
16
+ output, steps = Engine(strictness).run(text)
17
+ except Exception:
18
+ if raise_errors:
19
+ raise
20
+ return Result(text=text)
21
+ return Result(text=output, steps=steps)
@@ -0,0 +1,10 @@
1
+ # Data files
2
+
3
+ Built by `tools/build_data.py`. Not all of these are under the project's MIT licence.
4
+
5
+ | File | Source | Licence |
6
+ |---|---|---|
7
+ | `words.txt` | SCOWL 2020.12.07 (wordlist.aspell.net): the `english`, `american`, `british` and `british_z` lists up to size 60, without possessives | See `SCOWL-COPYRIGHT.txt`, which must stay with the list |
8
+ | `ngrams.txt` | Counts of four-letter sequences in twenty public-domain books from Project Gutenberg | MIT (our own compilation of public-domain text) |
9
+ | `scripts.txt` | Unicode `Scripts.txt`, version 18.0.0, with adjacent ranges merged | Unicode License V3, https://www.unicode.org/license.txt |
10
+ | `lookalikes.txt` | Unicode `confusables.txt`, version 18.0.0: the entries from a non-ASCII letter to ASCII letters | Unicode License V3, https://www.unicode.org/license.txt |
@@ -0,0 +1,248 @@
1
+ The collective work is Copyright 2000-2018 by Kevin Atkinson as well
2
+ as any of the copyrights mentioned below:
3
+
4
+ Copyright 2000-2018 by Kevin Atkinson
5
+
6
+ Permission to use, copy, modify, distribute and sell these word
7
+ lists, the associated scripts, the output created from the scripts,
8
+ and its documentation for any purpose is hereby granted without fee,
9
+ provided that the above copyright notice appears in all copies and
10
+ that both that copyright notice and this permission notice appear in
11
+ supporting documentation. Kevin Atkinson makes no representations
12
+ about the suitability of this array for any purpose. It is provided
13
+ "as is" without express or implied warranty.
14
+
15
+ Alan Beale <biljir@pobox.com> also deserves special credit as he has,
16
+ in addition to providing the 12Dicts package and being a major
17
+ contributor to the ENABLE word list, given me an incredible amount of
18
+ feedback and created a number of special lists (those found in the
19
+ Supplement) in order to help improve the overall quality of SCOWL.
20
+
21
+ The 10 level includes the 1000 most common English words (according to
22
+ the Moby (TM) Words II [MWords] package), a subset of the 1000 most
23
+ common words on the Internet (again, according to Moby Words II), and
24
+ frequently class 16 from Brian Kelk's "UK English Wordlist
25
+ with Frequency Classification".
26
+
27
+ The MWords package was explicitly placed in the public domain:
28
+
29
+ The Moby lexicon project is complete and has
30
+ been place into the public domain. Use, sell,
31
+ rework, excerpt and use in any way on any platform.
32
+
33
+ Placing this material on internal or public servers is
34
+ also encouraged. The compiler is not aware of any
35
+ export restrictions so freely distribute world-wide.
36
+
37
+ You can verify the public domain status by contacting
38
+
39
+ Grady Ward
40
+ 3449 Martha Ct.
41
+ Arcata, CA 95521-4884
42
+
43
+ grady@netcom.com
44
+ grady@northcoast.com
45
+
46
+ The "UK English Wordlist With Frequency Classification" is also in the
47
+ Public Domain:
48
+
49
+ Date: Sat, 08 Jul 2000 20:27:21 +0100
50
+ From: Brian Kelk <Brian.Kelk@cl.cam.ac.uk>
51
+
52
+ > I was wondering what the copyright status of your "UK English
53
+ > Wordlist With Frequency Classification" word list as it seems to
54
+ > be lacking any copyright notice.
55
+
56
+ There were many many sources in total, but any text marked
57
+ "copyright" was avoided. Locally-written documentation was one
58
+ source. An earlier version of the list resided in a filespace called
59
+ PUBLIC on the University mainframe, because it was considered public
60
+ domain.
61
+
62
+ Date: Tue, 11 Jul 2000 19:31:34 +0100
63
+
64
+ > So are you saying your word list is also in the public domain?
65
+
66
+ That is the intention.
67
+
68
+ The 20 level includes frequency classes 7-15 from Brian's word list.
69
+
70
+ The 35 level includes frequency classes 2-6 and words appearing in at
71
+ least 11 of 12 dictionaries as indicated in the 12Dicts package. All
72
+ words from the 12Dicts package have had likely inflections added via
73
+ my inflection database.
74
+
75
+ The 12Dicts package and Supplement is in the Public Domain.
76
+
77
+ The WordNet database, which was used in the creation of the
78
+ Inflections database, is under the following copyright:
79
+
80
+ This software and database is being provided to you, the LICENSEE,
81
+ by Princeton University under the following license. By obtaining,
82
+ using and/or copying this software and database, you agree that you
83
+ have read, understood, and will comply with these terms and
84
+ conditions.:
85
+
86
+ Permission to use, copy, modify and distribute this software and
87
+ database and its documentation for any purpose and without fee or
88
+ royalty is hereby granted, provided that you agree to comply with
89
+ the following copyright notice and statements, including the
90
+ disclaimer, and that the same appear on ALL copies of the software,
91
+ database and documentation, including modifications that you make
92
+ for internal use or for distribution.
93
+
94
+ WordNet 1.6 Copyright 1997 by Princeton University. All rights
95
+ reserved.
96
+
97
+ THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON
98
+ UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
99
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON
100
+ UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT-
101
+ ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
102
+ LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT INFRINGE ANY
103
+ THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
104
+
105
+ The name of Princeton University or Princeton may not be used in
106
+ advertising or publicity pertaining to distribution of the software
107
+ and/or database. Title to copyright in this software, database and
108
+ any associated documentation shall at all times remain with
109
+ Princeton University and LICENSEE agrees to preserve same.
110
+
111
+ The 40 level includes words from Alan's 3esl list found in version 4.0
112
+ of his 12dicts package. Like his other stuff the 3esl list is also in the
113
+ public domain.
114
+
115
+ The 50 level includes Brian's frequency class 1, words appearing
116
+ in at least 5 of 12 of the dictionaries as indicated in the 12Dicts
117
+ package, and uppercase words in at least 4 of the previous 12
118
+ dictionaries. A decent number of proper names is also included: The
119
+ top 1000 male, female, and Last names from the 1990 Census report; a
120
+ list of names sent to me by Alan Beale; and a few names that I added
121
+ myself. Finally a small list of abbreviations not commonly found in
122
+ other word lists is included.
123
+
124
+ The name files form the Census report is a government document which I
125
+ don't think can be copyrighted.
126
+
127
+ The file special-jargon.50 uses common.lst and word.lst from the
128
+ "Unofficial Jargon File Word Lists" which is derived from "The Jargon
129
+ File". All of which is in the Public Domain. This file also contain
130
+ a few extra UNIX terms which are found in the file "unix-terms" in the
131
+ special/ directory.
132
+
133
+ The 55 level includes words from Alan's 2of4brif list found in version
134
+ 4.0 of his 12dicts package. Like his other stuff the 2of4brif is also
135
+ in the public domain.
136
+
137
+ The 60 level includes all words appearing in at least 2 of the 12
138
+ dictionaries as indicated by the 12Dicts package.
139
+
140
+ The 70 level includes Brian's frequency class 0 and the 74,550 common
141
+ dictionary words from the MWords package. The common dictionary words,
142
+ like those from the 12Dicts package, have had all likely inflections
143
+ added. The 70 level also included the 5desk list from version 4.0 of
144
+ the 12Dics package which is in the public domain.
145
+
146
+ The 80 level includes the ENABLE word list, all the lists in the
147
+ ENABLE supplement package (except for ABLE), the "UK Advanced Cryptics
148
+ Dictionary" (UKACD), the list of signature words from the YAWL package,
149
+ and the 10,196 places list from the MWords package.
150
+
151
+ The ENABLE package, mainted by M\Cooper <thegrendel@theriver.com>,
152
+ is in the Public Domain:
153
+
154
+ The ENABLE master word list, WORD.LST, is herewith formally released
155
+ into the Public Domain. Anyone is free to use it or distribute it in
156
+ any manner they see fit. No fee or registration is required for its
157
+ use nor are "contributions" solicited (if you feel you absolutely
158
+ must contribute something for your own peace of mind, the authors of
159
+ the ENABLE list ask that you make a donation on their behalf to your
160
+ favorite charity). This word list is our gift to the Scrabble
161
+ community, as an alternate to "official" word lists. Game designers
162
+ may feel free to incorporate the WORD.LST into their games. Please
163
+ mention the source and credit us as originators of the list. Note
164
+ that if you, as a game designer, use the WORD.LST in your product,
165
+ you may still copyright and protect your product, but you may *not*
166
+ legally copyright or in any way restrict redistribution of the
167
+ WORD.LST portion of your product. This *may* under law restrict your
168
+ rights to restrict your users' rights, but that is only fair.
169
+
170
+ UKACD, by J Ross Beresford <ross@bryson.demon.co.uk>, is under the
171
+ following copyright:
172
+
173
+ Copyright (c) J Ross Beresford 1993-1999. All Rights Reserved.
174
+
175
+ The following restriction is placed on the use of this publication:
176
+ if The UK Advanced Cryptics Dictionary is used in a software package
177
+ or redistributed in any form, the copyright notice must be
178
+ prominently displayed and the text of this document must be included
179
+ verbatim.
180
+
181
+ There are no other restrictions: I would like to see the list
182
+ distributed as widely as possible.
183
+
184
+ The 95 level includes the 354,984 single words, 256,772 compound
185
+ words, 4,946 female names and the 3,897 male names, and 21,986 names
186
+ from the MWords package, ABLE.LST from the ENABLE Supplement, and some
187
+ additional words found in my part-of-speech database that were not
188
+ found anywhere else.
189
+
190
+ Accent information was taken from UKACD.
191
+
192
+ The VarCon package was used to create the American, British, Canadian,
193
+ and Australian word list. It is under the following copyright:
194
+
195
+ Copyright 2000-2016 by Kevin Atkinson
196
+
197
+ Permission to use, copy, modify, distribute and sell this array, the
198
+ associated software, and its documentation for any purpose is hereby
199
+ granted without fee, provided that the above copyright notice appears
200
+ in all copies and that both that copyright notice and this permission
201
+ notice appear in supporting documentation. Kevin Atkinson makes no
202
+ representations about the suitability of this array for any
203
+ purpose. It is provided "as is" without express or implied warranty.
204
+
205
+ Copyright 2016 by Benjamin Titze
206
+
207
+ Permission to use, copy, modify, distribute and sell this array, the
208
+ associated software, and its documentation for any purpose is hereby
209
+ granted without fee, provided that the above copyright notice appears
210
+ in all copies and that both that copyright notice and this permission
211
+ notice appear in supporting documentation. Benjamin Titze makes no
212
+ representations about the suitability of this array for any
213
+ purpose. It is provided "as is" without express or implied warranty.
214
+
215
+ Since the original words lists come from the Ispell distribution:
216
+
217
+ Copyright 1993, Geoff Kuenning, Granada Hills, CA
218
+ All rights reserved.
219
+
220
+ Redistribution and use in source and binary forms, with or without
221
+ modification, are permitted provided that the following conditions
222
+ are met:
223
+
224
+ 1. Redistributions of source code must retain the above copyright
225
+ notice, this list of conditions and the following disclaimer.
226
+ 2. Redistributions in binary form must reproduce the above copyright
227
+ notice, this list of conditions and the following disclaimer in the
228
+ documentation and/or other materials provided with the distribution.
229
+ 3. All modifications to the source code must be clearly marked as
230
+ such. Binary redistributions based on modified source code
231
+ must be clearly marked as modified versions in the documentation
232
+ and/or other materials provided with the distribution.
233
+ (clause 4 removed with permission from Geoff Kuenning)
234
+ 5. The name of Geoff Kuenning may not be used to endorse or promote
235
+ products derived from this software without specific prior
236
+ written permission.
237
+
238
+ THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
239
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
240
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241
+ ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
242
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
243
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
244
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
245
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
246
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
247
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
248
+ SUCH DAMAGE.