Networking

class chepy.modules.networking.Networking(*data)
defang_ip() NetworkingT

Make an IP address harmless

Takes a IPv4 or IPv6 address and ‘Defangs’ it, meaning the IP becomes invalid, removing the risk of accidentally utilising it as an IP address.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("2001:4860:4860::8844").defang_ip().o
"2001[:]4860[:]4860[:][:]8844"
>>> Chepy("127.0.0.1").defang_ip().o
"127[.]0[.]0[.]1"
defang_url() NetworkingT

Make a URL harmless

Takes a Universal Resource Locator (URL) and ‘Defangs’ it; meaning the URL becomes invalid, neutralising the risk of accidentally clicking on a malicious link. This is often used when dealing with malicious links or IOCs.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("https://app.google.com/?lol=some data&a=1").defang_url().o
"hxxps://app[.]google[.]com/?lol=some data&a=1"
get_ssl_cert(port: int = 443) NetworkingT

Get the server side SSL certificate for a domain

Parameters

port (int, optional) – Server port. Defaults to 443.

Returns

The Chepy object

Return type

Chepy

Examples

>>> Chepy('google.com').get_ssl_cert().o
{
    'subject': {
        'commonName': '*.google.com',
        'organizationName': 'Google LLC',
    ...
    'caIssuers': ('http://pki.goog/gsr2/GTS1O1.crt',),
    'crlDistributionPoints': ('http://crl.pki.goog/GTS1O1.crl',)
}
int_to_ip() NetworkingT

Convert an integer to an IP address

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(3232235777).int_to_ip().o
ip_to_int() NetworkingT

Convert an integer to an IP address

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(3232235777).int_to_ip().o
parse_ip_range() NetworkingT

Enumerate IP address in a CIDR range

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("10.10.10.1/24").parse_ip_range().o
[
    "10.10.10.1",
    "10.10.10.2,
    ...
    "10.10.10.254"
]
parse_ipv6() NetworkingT

Get longhand and shorthand of IPv6

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("2001:4860:4860::8888").parse_ipv6().o
{
    "long": "2001:4860:4860:0000:0000:0000:0000:8888",
    "short": "2001:4860:4860::8888",
}
parse_uri() NetworkingT

Parse a URI

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("http://example.com/resource?foo=bar#fragment").parse_uri().o
{
    "scheme": "http",
    "location": "example.com",
    "path": "/resource",
    "params": "",
    "query": {"foo": ["bar"]},
    "fragment": "fragment",
}
refang_ip() NetworkingT

Refangs an IP address

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("127[.]0[.]0[.]1").refang_ip().o
"127.0.0.1"
refang_url() NetworkingT

Refangs a URL so that it is clickable

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("hxxps://app[.]google[.]com/?lol=some data&a=1").refang_url().o
"https://app.google.com/?lol=some data&a=1"