-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import contextlib | ||
|
||
from credsweeper.config import Config | ||
from credsweeper.credentials import LineData | ||
from credsweeper.file_handler.analysis_target import AnalysisTarget | ||
from credsweeper.filters import Filter | ||
|
||
|
||
class ValueVinCheck(Filter): | ||
"""Check that value is a VIN""" | ||
WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2] | ||
TRANSLITERATIONS = { | ||
"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, | ||
"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "J": 1, "K": 2, | ||
"L": 3, "M": 4, "N": 5, "P": 7, "R": 9, "S": 2, "T": 3, "U": 4, "V": 5, "W": 6, | ||
"X": 7, "Y": 8, "Z": 9, | ||
} | ||
|
||
def __init__(self, config: Config = None) -> None: | ||
pass | ||
|
||
def run(self, line_data: LineData, target: AnalysisTarget) -> bool: | ||
"""Run filter checks on received credential candidate data 'line_data'. | ||
Args: | ||
line_data: credential candidate data | ||
target: multiline target from which line data was obtained | ||
Return: | ||
False, if the sequence is not card number. True if it is | ||
""" | ||
if line_data.value is None or 17 != len(line_data.value): | ||
return True | ||
|
||
with contextlib.suppress(Exception): | ||
int(line_data.value) | ||
return True | ||
|
||
# NHTSA (National Highway Traffic Safety Administration) | ||
# https://en.wikipedia.org/wiki/Vehicle_identification_number | ||
with contextlib.suppress(Exception): | ||
s = 0 | ||
for w, v in zip(ValueVinCheck.WEIGHTS, line_data.value): | ||
s += w * ValueVinCheck.TRANSLITERATIONS[v] | ||
r = s % 11 | ||
if "X" == line_data.value[8] and 10 == r: | ||
return False | ||
elif int(line_data.value[8]) == r: | ||
return False | ||
|
||
# return False when the sequence has wrong check digit | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# fake or not NHTSA | ||
00000000000000000 | ||
98374914723492346 | ||
M9AX4278X1MKP08GD | ||
# valid | ||
1M8GDM9AXKP042788 |