{"id":20976086,"url":"https://github.com/nokka/d2s","last_synced_at":"2025-10-27T22:43:58.407Z","repository":{"id":43335679,"uuid":"77741810","full_name":"nokka/d2s","owner":"nokka","description":"Diablo II file format binary parser written in Go.","archived":false,"fork":false,"pushed_at":"2022-03-08T20:11:13.000Z","size":530,"stargazers_count":157,"open_issues_count":7,"forks_count":33,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-08-30T05:37:08.666Z","etag":null,"topics":["binary-parser","diablo-ii","game","reverse-engineering"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nokka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-31T13:42:12.000Z","updated_at":"2025-08-16T13:24:59.000Z","dependencies_parsed_at":"2022-09-09T04:26:56.814Z","dependency_job_id":null,"html_url":"https://github.com/nokka/d2s","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/nokka/d2s","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nokka%2Fd2s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nokka%2Fd2s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nokka%2Fd2s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nokka%2Fd2s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nokka","download_url":"https://codeload.github.com/nokka/d2s/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nokka%2Fd2s/sbom","scorecard":{"id":693373,"data":{"date":"2025-08-11","repo":{"name":"github.com/nokka/d2s","commit":"426ae713940b7474a5f7872f16dddb02ced8a241"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":4,"reason":"Found 5/12 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 27 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T02:53:15.001Z","repository_id":43335679,"created_at":"2025-08-22T02:53:15.001Z","updated_at":"2025-08-22T02:53:15.001Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281355366,"owners_count":26486896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-parser","diablo-ii","game","reverse-engineering"],"created_at":"2024-11-19T04:49:51.663Z","updated_at":"2025-10-27T22:43:58.376Z","avatar_url":"https://github.com/nokka.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Diablo II character file parser\n[![Go Report Card](https://goreportcard.com/badge/github.com/nokka/d2s)](https://goreportcard.com/report/github.com/nokka/d2s)\n[![GoDoc](https://godoc.org/github.com/nokka/d2s?status.svg)](https://godoc.org/github.com/nokka/d2s)\n\nD2s is a binary parser written in Go that's used to parse `.d2s` files. This is the binary format that the game [Diablo II](http://eu.blizzard.com/en-gb/games/d2/) uses to save all information about a certain character. \n\n## Motivation\nThis package was built for a private server of Diablo II called [Slash Diablo](https://www.reddit.com/r/slashdiablo/) to build an Armory for all characters on the server. Where anyone could see everything about a particular character at any given point in time. Here's a few examples.\n\n* [nokkasorc](https://armory.slashdiablo.net/character/nokkasorc#equipped)\n* [bluntakira](https://armory.slashdiablo.net/character/bluntakira#equipped)\n* [freremort](https://armory.slashdiablo.net/character/freremort#equipped)\n\n## Install\n\n```bash\n$ go get github.com/nokka/d2s\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/nokka/d2s\"\n)\n\nfunc main() {\n\tpath := \"nokka.d2s\"\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\tlog.Fatal(\"Error while opening .d2s file\", err)\n\t}\n\n\tdefer file.Close()\n\n\tchar, err := d2s.Parse(file)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Prints character name and class.\n\tfmt.Println(char.Header.Name)\n\tfmt.Println(char.Header.Class)\n}\n\n```\n\n## Binary layout\n\n### Header\nThe header is `765 byte` long struct containing most of the character meta data.\n\nOffset | Bytes | Description\n-----|-------- |------------\n0    | 4       | Identifier\n4    | 4       | Version ID\n8    | 4       | File size\n12   | 4       | Checksum\n16   | 4       | Active weapon\n20   | 16      | [Character Name](#character-name)\n36   | 1       | [Character Status](#character-status)\n37   | 1       | [Character progression](#character-progression)\n38   | 2       | Unknown\n40   | 1       | [Character Class](#character-class)\n41   | 2       | Unknown\n43   | 1       | Character Level\n44   | 4       | Unknown\n48   | 4       | [Last played](#last-played)\n52   | 4       | Unknown\n56   | 64      | [Assigned skills](#assigned-skills)\n120   | 4      | Left mouse button skill ID\n124   | 4      | Right mouse button skill ID\n128   | 4      | Left swap mouse button skill ID\n132   | 4      | Right swap mouse button skill ID\n136   | 32     | Character menu appearance\n168   | 3      | Difficulty\n171   | 4      | Map ID\n175   | 2      | Unknown\n177   | 2      | Mercenary dead\n179   | 4      | Mercenary ID\n183   | 2      | Mercenary Name ID\n185   | 2      | Mercenary type\n187   | 4      | Mercenary experience\n191   | 144      | Unknown\n335   | 298      | [Quests](#quests)\n633   | 81      | [Waypoints](#waypoints)\n714   | 51      | [NPC Introductions](#npc-introductions)\n\n#### Character name\n\nCharacter names are storted as a `[16]byte` which will contain the name, one letter per `byte`. The name can be 16 characters long, and a name that's shorter will have padded `0x00`'s behind the name until we reach `16 bytes`.\n\n * Must be 2-15 in length\n * Must begin with a letter\n * May contain up to one `-` or `_`.\n\n#### Character status\nCharacter status is a `byte` where different bits will be set, depending on the status of the character. Still haven't figured them all out, but here's the most important ones.\n\n##### Bit position\n\n| 7 | 6      | 5         | 4 | 3    | 2        | 1 | 0 |\n|---|--------|-----------|---|------|----------|---|---|\n| ? | Ladder | Expansion | ? | Died | Hardcore | ? | ? |\n\n#### Character progression \n\u003eNot implemented yet.\n\nThe value is incremented every time you kill an act boss.\n\n##### Classic\n| Value | Standard       | Hardcore       |\n|-------|----------------|----------------|\n| 0-3   | -              | -              |\n| 4-7   | Sir/Dame       | Count/Countess |\n| 8-11  | Lord/Lady      | Duke/Duchess   |\n| 12    | Baron/Baroness | King/Queen     |\n\n##### Expansion\n| Value | Expansion           | Expansion hardcore |\n|-------|---------------------|--------------------|\n| 0-3   | -                   | -                  |\n| 5-8   | Slayer              | Destroyer          |\n| 10-13 | Champion            | Conqueror          |\n| 15    | Patriarch/Matriarch | Guardian           |\n\n\n#### Character class\nCharacter class is a `byte` where different values represent a class.\n\n|    Class    |  Value |\n|:-----------:|:------:|\n| Amazon      | `0x00` |\n| Sorceress   | `0x01` |\n| Necromancer | `0x02` |\n| Paladin     | `0x03` |\n| Barbarian   | `0x04` |\n| Druid       | `0x05` |\n| Assassin    | `0x06` |\n\n#### Last played\nLast played is saved as a `unit32` [unix timestamp](https://en.wikipedia.org/wiki/Unix_time) e.g `1495882861`.\n\n#### Assigned skills\nAssigned skills section is a an array of 16 [skill ids](skills.go#29), each a `4 byte` integer (uint32). If no skill is assigned the value is `0x00`.\n\n#### Quests\nThe quests struct is `298 byte` section that describes all quests in the game but also contains data about act traveling and NPC introductions. Each quest is `2 byte` long.\n\n##### Header\n| Offset | Bytes | Content |\n|--------|-------|---------|\n| 335    | 4     | Woo!    |\n| 339    | 6     | Unknown |\n\n##### Quest structs\nA quest is `2 byte` long, I've created a general `quest` struct that holds the most important data of a quest, if it's completed or not. Each quest has a lot of unique bits set depending on different milestones of the quest. For example if you've consumed the Scroll of Resistance from the quest \"Prison of Ice\" or not.\n\n##### General \n| Bit | Description     |\n|-----|-----------------|\n| 0   | Quest completed |\n\n##### Prison of Ice\n[Prison of Ice ](quest.go#L26)is the only quest I bothered to implement, because I needed to know if the character has increased resistances from the scroll or not.\n\n| Bit | Description     |\n|-----|-----------------|\n| 0   | Quest completed |\n| 7   | Consumed scroll |\n\n##### Quest structure\nThis structure repeats it self 3 times, once for Normal, Nightmare and Hell. The offset is the offset into the quest struct.\n\n| Offset | Bytes      | Description                                                                             |\n|--------|------------|-----------------------------------------------------------------------------------------|\n| 0      | `2`        | Set to `1` if you have been introduced to Warriv in Act I.                              |\n| 2      | `[6]quest` | All six quests for Act I.                                                               |\n| 14     | `2`        | Set to `1` if you have traveled to Act II.                                              |\n| 16     | `2`        | Set to `1` if you have been introduced to Jerhyn.                                       |\n| 18     | `[6]quest` | All six quests for Act II.                                                              |\n| 30     | `2`        | Set to `1` if you have traveled to Act III.                                             |\n| 32     | `2`        | Set to `1` if you have been introduced to Hratli.                                       |\n| 34     | `[6]quest` | All six quests for Act III.                                                             |\n| 46     | `2`        | Set to `1` if you have traveled to Act IV.                                              |\n| 48     | `2`        | Set to `1` if you have been introduced to Act IV. (which you have if you have traveled) |\n| 50     | `[6]quest` | Act IV only has 3 quests, so the struct has 6 empty bytes here.                         |\n| 62     | `2`        | Set to `1` if you have traveled to Act V.                                               |\n| 64     | `2`        | Seems to be set to 1 after completing Terror's End and talking to Cain in act IV.       |\n| 66     | `4`        | Seems to be some kind of padding.                                                       |\n| 70     | `[6]quest` | All six quests for Act V.                                                               |\n| 82     | 14         | Some kind of padding after all the quest data.                                          |\n\n#### Waypoints\n\u003e Not implemented\n\n#### NPC Introductions\n\u003e Not implemented\n\n### Attributes\nFollowing the header is the attributes section, this sections layout consists of an array of  `9 bit` attribute id, followed by a `n bit` length attribute value. The section is terminated by a `9 bit` value of `0x1ff`. It's worth mentioning that these fields are [bit reversed](bitreader.go#L69). Basically if you find the bits `00100111` they are reversed into `11100100`.  \n\n#### Attribute IDs\n| ID | Attribute       |\n|----|-----------------|\n| 0  | Strength        |\n| 1  | Energy          |\n| 2  | Dexterity       |\n| 3  | Vitality        |\n| 4  | Unused stats    |\n| 5  | Unused skills   |\n| 6  | Current HP      |\n| 7  | Max HP          |\n| 8  | Current mana    |\n| 9  | Max mana        |\n| 10 | Current stamina |\n| 11 | Max stamina     |\n| 12 | Level           |\n| 13 | Experience      |\n| 14 | Gold            |\n| 15 | Stashed gold    |\n\n#### Attribute bit lengths\n| Bit length | Attribute       |\n|------------|-----------------|\n| 10         | Strength        |\n| 10         | Energy          |\n| 10         | Dexterity       |\n| 10         | Vitality        |\n| 10         | Unused stats    |\n| 8          | Unused skills   |\n| 21         | Current HP      |\n| 21         | Max HP          |\n| 21         | Current mana    |\n| 21         | Max mana        |\n| 21         | Current stamina |\n| 21         | Max stamina     |\n| 7          | Level           |\n| 32         | Experience      |\n| 25         | Gold            |\n| 25         | Stashed gold    |\n\n#### Example of the reading\n\n```go\nfor {\n    // 1. read 9 bits id. (reverse them)\n    // 2. if the id is 0x1ff, terminate the loop\n    // 3. read bit length from attribute map for that id.\n    // 4. read bit length nr of bits. \n}\n```\n\n### 3. Skills\nSkills are a `32 byte` section containing a `2 byte` header with the value `if` and `30 byte` of skill data. Each class has 30 skills available to them, so each skill get `1 byte` each. The tricky part about the skill mapping is that each class has a different offset into the [skill map](skills.go#L29) where their class specific skills start, and then go 30 indexes into the map. So for example Assassin has an offset of `251`. Which means Assassin skills are  between the indexes of `251` and `281` which is exactly 30 indexes.\n\n##### Layout\n|  Type  | Bytes | Value                     |\n|:------:|:-----:|---------------------------|\n| Header | `2`   | `if`                      |\n| Skills | `30`  | [[30]skill](skills.go#L29) |\n\n##### Skill offset map\n|    Class    | Offset |\n|:-----------:|:------:|\n| Amazon      | `6`    |\n| Sorceress   | `36`   |\n| Necromancer | `66`   |\n| Paladin     | `96`   |\n| Barbarian   | `126`  |\n| Druid       | `221`  |\n| Assassin    | `251`  |\n\n### 4. Items\nThis is by far the most tricky part to read. The items section starts of with a `4 byte` header, containing the value `JM`, and a `uint16` value which is the item count your character currently has. Equipped, inventory, stash, cube and belt all included.\n\nThe byte length of the section is unknown before reading it in it's entirety, because the bit length of each item varies depending on its quality, number of sockets and magical attributes it possess.\n\nEach item follows a certain pattern though, which is:\n\n#### Simple items\nEach item starts of with `111` bits of simple data, which all items contain. This is information like item type, if it's socketed, position id like equipped or stash and so on.\n\nEach item also has a boolean called `SimpleItem` which is `1` bit long,  if this is set to `1`, the item contains no more bits, and the next item starts.\n\n#### Advanced items\nIf the item is not a simple items, this means it will have tons of data following the initial `111` bits. A few examples of this is the rarity level, magical suffix, magical affix, if it's a runeword, personalized, part of a set, class specific and so on. \n\nLast but not least if the item has will have lists of magical properties depending on if it's a runeword, magical, rare, crafted, unique part of set and so on.\n\nThese lists are similar to the attributes section where we will read:\n\n1. `9 bit id`\n2. `n bits of magical properties`\n3. `0x1ff terminator`\n\nWhen we hit the terminator `0x1ff` the next item begins.\n\n#### Magical properties\nA magical property is a unique property that can occur on an item, each property has a different bit length, and the map is huge.\n\n##### Example\n\nThis is the magical property with id `83` which contains 2 bit fields each `3` bits long.\n```go\n83: {Bits: []uint{3, 3}, Name: \"+{1} to {0} Skill Levels\"},\n```\n\nAll magical properties are mapped in the [item.go](item.go) file.\n\n### 5. Corpse data\nIf your character is currently dead, and a corpse is on the ground when you enter a game, your equipped items will be in this item struct. It's a corpse header `16 bytes` containing the header `JM` followed by an item count similar to the item list.\n\nReading the corpse items are done in the exact way as the previous section of items.\n\n### 6. Expansion data\nIf your character is created in the expansion Lord of Destruction if will contain 2 more sections.\n\n#### 7. Mercenary items\nThe mercenary sections starts of with a `2 byte` header with the value `jf` and is followed by a `4 byte` item header containing the number of items the mercenary is currently wearing. The items are read like any other item list.\n\n#### 8. Golem\nIf your character is both a Necromancer and an expansion character, this section starts of with a `3 byte` header, where the first two bytes are the header `kf` followed by a boolean called `hasGolem`, if this value is true, there's an item list with the length 1 following the header.\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](/CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnokka%2Fd2s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnokka%2Fd2s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnokka%2Fd2s/lists"}