{"id":5964,"library":"impacket","title":"Impacket","description":"Impacket is a collection of Python classes and scripts for working with network protocols. It provides programmatic access to low-level protocol details, allowing users to construct and parse packets for protocols like SMB, DCE/RPC, LDAP, and Kerberos. Widely used in penetration testing and security research, it enables interacting with network services, performing authentication, and exploiting protocol-level vulnerabilities. The current version is 0.13.0, with regular updates addressing new features and security fixes.","status":"active","version":"0.13.0","language":"en","source_language":"en","source_url":"https://github.com/fortra/impacket","tags":["network","protocol","smb","ldap","dcerpc","kerberos","security","pentesting"],"install":[{"cmd":"pip install impacket","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Commonly used for interacting with SMB services.","symbol":"SMBConnection","correct":"from impacket.smb import SMBConnection"},{"note":"For interacting with LDAP servers.","symbol":"LDAPSession","correct":"from impacket.ldap import LDAPSession"},{"note":"The `msdcerpc` module was merged into `dcerpc` in version 0.10.0.","wrong":"from impacket.msdcerpc import dcerpc","symbol":"dcerpc","correct":"from impacket.dcerpc.v5 import dcerpc"}],"quickstart":{"code":"import os\nfrom impacket.smb import SMBConnection\n\n# --- Configuration (replace with your environment variables or actual values) ---\nTARGET_IP = os.environ.get('IMPACKET_TARGET_IP', '127.0.0.1')\nUSERNAME = os.environ.get('IMPACKET_USERNAME', 'guest')\nPASSWORD = os.environ.get('IMPACKET_PASSWORD', '')\nDOMAIN = os.environ.get('IMPACKET_DOMAIN', '') # Often empty for local accounts\n\nif not TARGET_IP:\n    print(\"Please set IMPACKET_TARGET_IP environment variable or replace '127.0.0.1' with an actual SMB server IP.\")\n    exit(1)\n\ntry:\n    print(f\"Attempting to connect to SMB share on {TARGET_IP} as {DOMAIN}\\\\{USERNAME}...\")\n    smb_conn = SMBConnection(TARGET_IP, TARGET_IP)\n    smb_conn.login(USERNAME, PASSWORD, DOMAIN)\n    print(\"Login successful!\")\n\n    shares = smb_conn.listShares()\n    print(\"\\nAvailable Shares:\")\n    for share in shares:\n        print(f\"  - {share['name'].decode('utf-8')}\")\n\n    smb_conn.logoff()\n    print(\"\\nLogged off.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure the target SMB server is reachable and credentials are correct.\")\n    print(\"For a quick test, you might need a local SMB server (e.g., Samba on Linux, or Windows share).\")","lang":"python","description":"This quickstart demonstrates how to establish an SMB connection, authenticate, and list available shares using `impacket.smb.SMBConnection`. It fetches sensitive information from environment variables for security and flexibility."},"warnings":[{"fix":"Ensure your environment uses Python 3.7+ and adapt any Python 2 specific code constructs.","message":"Impacket versions 0.9.20 and later are exclusively Python 3. If upgrading from older versions (pre-0.9.20), significant code changes may be required for Python 2 compatibility.","severity":"breaking","affected_versions":"<0.9.20 to >=0.9.20"},{"fix":"Migrate to NTLMv2 or Kerberos for authentication. Ensure target systems support stronger authentication protocols.","message":"NTLMv1 challenge/response authentication has been deprecated and removed due to security vulnerabilities. Attempts to use NTLMv1 will fail.","severity":"breaking","affected_versions":">=0.9.21"},{"fix":"Update all imports from `impacket.msdcerpc` to `impacket.dcerpc.v5`. For example, `from impacket.msdcerpc.v5 import dcomrt` becomes `from impacket.dcerpc.v5 import dcomrt`.","message":"The `impacket.msdcerpc` module was merged into `impacket.dcerpc.v5` for better organization. Imports from `impacket.msdcerpc` will no longer work.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Ensure proper DNS resolution for target domains/hosts or explicitly provide KDC host information where applicable (e.g., in `SMBConnection` constructor or Kerberos functions).","message":"Many Impacket functionalities, especially those related to Kerberos, require specific DNS configurations or KDC (Key Distribution Center) host information to be correctly resolved or provided.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}