Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex for more crypto wallets, IPv6 and improved coordinates #26

Closed
wants to merge 4 commits into from

Conversation

amadejpapez
Copy link
Collaborator

  • pyWhat can now detect Ripple, Bitcoin Cash, Litecoin and Monero!
  • added detection for IPv6
  • if there is a port number alongside of the IP address, it will now grab that too
  • improved detection for coordinates, added formats (N 32° 53.733 W 096° 48.358") and made it less restrictive (20,80 is no longer a coordinate :D)

},
{
"Name": "Bitcoin Cash (BCH) Wallet Address",
"Regex": "^bitcoincash:[a-zA-Z0-9]{42}$",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much higher as it says bitcoincash at the front, i'd give it a rarity of 1.0

@@ -251,15 +291,25 @@
]
},
{
"Name": "Internet Protocol (IP) Address",
"Regex": "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
"Name": "Internet Protocol (IP) Address version 4",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalise Version here :-)

"Description": "Universal address pointing to an entity on the web.",
"Rarity": 0.4,
"Tags": [
"Identifiers",
"Networking"
]
},
{
"Name": "Internet Protocol (IP) Address version 6",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalise version here!

"Name": "Internet Protocol (IP) Address version 6",
"Regex": "\\[?(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\\]?(:[0-9]{1,5})?",
"Description": "Universal address pointing to an entity on the web.",
"Rarity": 1.0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please manually sort them in the file, so the ones with the highest rarity (1.0) go at the top and the lower the rarity the lower down in the file they are.

this is so when we import via JSON it's already sorted most likely (least false positives) to least likely (most false positives) :D

pywhat/printer.py Outdated Show resolved Hide resolved
Comment on lines +121 to +142
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(["47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"])
assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]


def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]


def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]


def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is annoying, but can you also add all the tests to:
https://github.com/bee-san/pyWhat/blob/main/fixtures/file

And copy / paste into:
https://github.com/bee-san/pyWhat/blob/main/tests/test_click.py

Because of how many regexes this has, we need to be on the ball with testing. We need to have a lot of tests to make sure we don't slip up :-)

Comment on lines 96 to 98
"YouTube Video ID": "https://www.youtube.com/watch?v=",
"YouTube Channel ID": "https://www.youtube.com/channel/",
"Latitude & Longitude Coordinates": "https://www.google.com/maps/place/",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include the Shodan link here for IP addresses, please?
https://www.shodan.io/search?query=6.6.6.6

for 6.6.6.6 :-)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the URL is this:

https://www.shodan.io/host/118.103.238.230

Comment on lines 90 to 92
"Ethereum (ETH) Wallet Address": "https://etherscan.io/address/",
"Dogecoin (DOGE) Wallet Address": "https://dogechain.info/address/",
"Bitcoin (BTC) Wallet Address": "https://www.blockchain.com/btc/address/",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this is annoying -- but can we test that these links show up? You can do so by:
This is annoying, but can you also add all the tests to:
https://github.com/bee-san/pyWhat/blob/main/fixtures/file

And copy / paste into:
https://github.com/bee-san/pyWhat/blob/main/tests/test_click.py

and then in that Click file trying to match the dogechain / etherscan URL etc :-) (I'd just do re.searchall("dogechain") to find it 😄

Comment on lines 96 to 98
"YouTube Video ID": "https://www.youtube.com/watch?v=",
"YouTube Channel ID": "https://www.youtube.com/channel/",
"Latitude & Longitude Coordinates": "https://www.google.com/maps/place/",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the URL is this:

https://www.shodan.io/host/118.103.238.230

@@ -10,7 +10,7 @@
]
},
{
"Name": "Bitcoin Wallet",
"Name": "Bitcoin (BTC) Wallet Address",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps include the bitcoin char here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants