nefile


Namenefile JSON
Version 0.9.2 PyPI version JSON
download
home_page
SummaryParse 16-bit New Executable (NE) programs.
upload_time2023-09-24 15:50:38
maintainer
docs_urlNone
authornpjg
requires_python>=3.9
licenseMIT License Copyright (c) 2022 Nathanael Gentry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords struct reverse-engineering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Like its namesake [`pefile`](https://github.com/erocarrera/pefile) does for the modern Portable Executable format, this `nefile` library parses the ancient 16-bit New Executable (NE) format. 

I drafted this library because here are not many good cross-platform tools for analyzing and extracting data (more than just code) from NE files. For instance, Ghidra is great at decompilation but not really at resources. `wrestool` and `icoutils` are the only tools I have found to date that can extract resources from NE files, but I ran into multiple issues using `wrestool`, including resources being corrupted upon extraction. 

This library fills the gap. Also, I just love Windows 3.1.

Currently there is read-only support for the NE header and resources, as that's all I need at the moment. Feel free to contribute if you need other functionality from Python!

## Spec References
The main spec reference used is the Microsoft Windows 3.1 Programmer's Reference, Volume 4 (Resources), referred to 
in the code as `W3.1PRV4`. 

The Microsoft MS-DOS Programmer's Reference helped provide insight into the DOS MZ header. 

## Installation
Get it [on PyPI](https://pypi.org/project/nefile/): ```pip3 install nefile```

## Usage

```python
import nefile
from nefile.resource_table import ResourceType

# OPEN THE WINDOWS 3.1 PROGRAM MANAGER.
progman = nefile.NE('/media/windows-3.1/WINDOWS/PROGMAN.EXE')
print(progman.header.target_operating_system) # <TargetOperatingSystem.WINDOWS_3X: 2>
print(progman.header.expected_windows_version) # 3.10
# See the resource types defined in Program Manager.
print(progman.resource_table.resource_type_tables.keys())
# Known resource types are replaced with an enum member. There can also be integer and string IDs
# for resource types that don't have a globally-defined type.
# dict_keys([<ResourceType.RT_GROUP_ICON: 14>, <ResourceType.RT_MENU: 4>, <ResourceType.RT_DIALOG: 5>, 
#            <ResourceType.RT_STRING: 6>, <ResourceType.RT_ACCELERATOR: 9>, <ResourceType.RT_VERSION: 16>,
#            <ResourceType.RT_ICON: 3>])
# 
# List all the bitmap resources defined in Program Manager.
print(progman.resource_table.resource_type_tables[ResourceType.RT_GROUP_ICON])
# Individual resource IDs are either integer or string IDs, as dictated in the file.
# {3: <nefile.resources.Resource object at 0x7f0d72c79fa0>, 6: <nefile.resources.Resource object at 0x7f0d72c7af40>, 
#  'DATAICON': <nefile.resources.Resource object at 0x7f0d72c7a0d0>, 'COMMICON': <nefile.resources.Resource object at 0x7f0d72c7afd0>, 
#  'MSDOSICON': <nefile.resources.Resource object at 0x7f0d72c7ab80>}

# OPEN THE WINDOWS 3.1 SHELL.
# This is where the famous easter egg is stored! I actually wrote this library
# because I wanted to get at those resources solely in Python and not bother
# with `wrestool`.
shell = nefile.NE('/media/windows-3.1/WINDOWS/SYSTEM/SHELL.DLL')
# dict_keys([<ResourceType.RT_BITMAP: 2>, <ResourceType.RT_DIALOG: 5>, <ResourceType.RT_STRING: 6>, 
#            <ResourceType.RT_RCDATA: 10>, <ResourceType.RT_VERSION: 16>, 100])
shell.export_resources("/root/shell")
# Produces files with names like "SHELL.DLL-RT_BITMAP-130.bmp".
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nefile",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "struct,reverse-engineering",
    "author": "npjg",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/0d/bc/3257784725311ab7dafe2c77bab2a3b605647d59de0ea132632b9b26e969/nefile-0.9.2.tar.gz",
    "platform": null,
    "description": "Like its namesake [`pefile`](https://github.com/erocarrera/pefile) does for the modern Portable Executable format, this `nefile` library parses the ancient 16-bit New Executable (NE) format. \n\nI drafted this library because here are not many good cross-platform tools for analyzing and extracting data (more than just code) from NE files. For instance, Ghidra is great at decompilation but not really at resources. `wrestool` and `icoutils` are the only tools I have found to date that can extract resources from NE files, but I ran into multiple issues using `wrestool`, including resources being corrupted upon extraction. \n\nThis library fills the gap. Also, I just love Windows 3.1.\n\nCurrently there is read-only support for the NE header and resources, as that's all I need at the moment. Feel free to contribute if you need other functionality from Python!\n\n## Spec References\nThe main spec reference used is the Microsoft Windows 3.1 Programmer's Reference, Volume 4 (Resources), referred to \nin the code as `W3.1PRV4`. \n\nThe Microsoft MS-DOS Programmer's Reference helped provide insight into the DOS MZ header. \n\n## Installation\nGet it [on PyPI](https://pypi.org/project/nefile/): ```pip3 install nefile```\n\n## Usage\n\n```python\nimport nefile\nfrom nefile.resource_table import ResourceType\n\n# OPEN THE WINDOWS 3.1 PROGRAM MANAGER.\nprogman = nefile.NE('/media/windows-3.1/WINDOWS/PROGMAN.EXE')\nprint(progman.header.target_operating_system) # <TargetOperatingSystem.WINDOWS_3X: 2>\nprint(progman.header.expected_windows_version) # 3.10\n# See the resource types defined in Program Manager.\nprint(progman.resource_table.resource_type_tables.keys())\n# Known resource types are replaced with an enum member. There can also be integer and string IDs\n# for resource types that don't have a globally-defined type.\n# dict_keys([<ResourceType.RT_GROUP_ICON: 14>, <ResourceType.RT_MENU: 4>, <ResourceType.RT_DIALOG: 5>, \n#            <ResourceType.RT_STRING: 6>, <ResourceType.RT_ACCELERATOR: 9>, <ResourceType.RT_VERSION: 16>,\n#            <ResourceType.RT_ICON: 3>])\n# \n# List all the bitmap resources defined in Program Manager.\nprint(progman.resource_table.resource_type_tables[ResourceType.RT_GROUP_ICON])\n# Individual resource IDs are either integer or string IDs, as dictated in the file.\n# {3: <nefile.resources.Resource object at 0x7f0d72c79fa0>, 6: <nefile.resources.Resource object at 0x7f0d72c7af40>, \n#  'DATAICON': <nefile.resources.Resource object at 0x7f0d72c7a0d0>, 'COMMICON': <nefile.resources.Resource object at 0x7f0d72c7afd0>, \n#  'MSDOSICON': <nefile.resources.Resource object at 0x7f0d72c7ab80>}\n\n# OPEN THE WINDOWS 3.1 SHELL.\n# This is where the famous easter egg is stored! I actually wrote this library\n# because I wanted to get at those resources solely in Python and not bother\n# with `wrestool`.\nshell = nefile.NE('/media/windows-3.1/WINDOWS/SYSTEM/SHELL.DLL')\n# dict_keys([<ResourceType.RT_BITMAP: 2>, <ResourceType.RT_DIALOG: 5>, <ResourceType.RT_STRING: 6>, \n#            <ResourceType.RT_RCDATA: 10>, <ResourceType.RT_VERSION: 16>, 100])\nshell.export_resources(\"/root/shell\")\n# Produces files with names like \"SHELL.DLL-RT_BITMAP-130.bmp\".\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Nathanael Gentry  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Parse 16-bit New Executable (NE) programs.",
    "version": "0.9.2",
    "project_urls": {
        "Homepage": "https://github.com/npjg/nefile"
    },
    "split_keywords": [
        "struct",
        "reverse-engineering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "426c43057fe9892cdfa6a0fde464e251ff2dc605522451d873093ca28d857e33",
                "md5": "fe738adad7a88c0fa4a377a26e0d2b27",
                "sha256": "2f2e236cb888f00772f09b26a7647431859d83ef94cd9645b27818f17455a8e7"
            },
            "downloads": -1,
            "filename": "nefile-0.9.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe738adad7a88c0fa4a377a26e0d2b27",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 20938,
            "upload_time": "2023-09-24T15:50:37",
            "upload_time_iso_8601": "2023-09-24T15:50:37.243352Z",
            "url": "https://files.pythonhosted.org/packages/42/6c/43057fe9892cdfa6a0fde464e251ff2dc605522451d873093ca28d857e33/nefile-0.9.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0dbc3257784725311ab7dafe2c77bab2a3b605647d59de0ea132632b9b26e969",
                "md5": "d4829ba75507a7c8e438aa3ca001bd74",
                "sha256": "181b1b920036194da773c1b42a5b6eac1c5ec622ad169abb65abc12f56d96c96"
            },
            "downloads": -1,
            "filename": "nefile-0.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d4829ba75507a7c8e438aa3ca001bd74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 17520,
            "upload_time": "2023-09-24T15:50:38",
            "upload_time_iso_8601": "2023-09-24T15:50:38.322274Z",
            "url": "https://files.pythonhosted.org/packages/0d/bc/3257784725311ab7dafe2c77bab2a3b605647d59de0ea132632b9b26e969/nefile-0.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-24 15:50:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "npjg",
    "github_project": "nefile",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nefile"
}
        
Elapsed time: 0.11496s