Skip to content

Commit 24d4e00

Browse files
committed
Rework readpe
1 parent c220343 commit 24d4e00

97 files changed

Lines changed: 11917 additions & 8144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/multi-os-build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ jobs:
1818
with:
1919
# Space-separated list of packages to install using apt-get. Will only run if on ubuntu.
2020
apt-get: libssl-dev
21-
21+
2222
- name: Checkout with submodules
2323
uses: actions/checkout@v3
2424
with:
2525
submodules: 'true'
2626

2727
- name: Compile
2828
run: make
29-
30-
29+
30+
3131
build-osx:
3232

3333
runs-on: macos-latest
@@ -39,15 +39,15 @@ jobs:
3939
with:
4040
# Space-separated list of packages to install using brew install. Will only run if on OSX.
4141
brew: openssl
42-
42+
4343
- name: Checkout with submodules
4444
uses: actions/checkout@v3
4545
with:
4646
submodules: 'true'
4747

4848
- name: Compile
4949
run: CFLAGS="-I/usr/local/opt/openssl/include/" LDFLAGS="-L/usr/local/opt/openssl/lib/" make
50-
50+
5151
build-win64:
5252

5353
runs-on: windows-latest
@@ -62,14 +62,14 @@ jobs:
6262
platform: x64 # optional, default is x64
6363
install-dir: c:\tools\cygwin # optional, default is C:\tools\cygwin
6464
packages: gcc-core binutils make zip libssl-devel # optional
65-
65+
6666
- name: Checkout with submodules
6767
uses: actions/checkout@v3
6868
with:
6969
submodules: 'true'
7070

7171
- name: Compile
7272
run: make
73-
73+
7474
- name: Compile Windows-only tools and create a ZIP package
7575
run: make zip
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: win-artifact-build
2+
3+
on:
4+
push:
5+
branches: [ build ]
6+
7+
jobs:
8+
build-win64:
9+
10+
runs-on: windows-latest
11+
12+
steps:
13+
14+
- name: Install Cygwin
15+
# You may pin to the exact commit or the version.
16+
# uses: egor-tensin/setup-cygwin@4f96f9fecb8c952fa32ff791b0a77d93d5191bb4
17+
uses: egor-tensin/setup-cygwin@v3
18+
with:
19+
platform: x64 # optional, default is x64
20+
install-dir: c:\tools\cygwin # optional, default is C:\tools\cygwin
21+
packages: gcc-core binutils make zip libssl-devel # optional
22+
23+
- name: Checkout with submodules
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: 'true'
27+
28+
- name: Compile
29+
run: make
30+
31+
- name: Compile Windows-only tools and create a ZIP package
32+
run: make zip
33+
34+
- name: Upload Artifact
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: win-build
38+
path: ./*.zip
39+
retention-days: 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Debug
1515
*.dSYM
1616
*.log
1717
.settings
18+
build/**
1819
src/ofs2rva
1920
src/output
2021
src/pedis

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
project(readpe)
3+
4+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5+
6+
option(BUILD_STATIC "Build static executable" Off)
7+
8+
add_subdirectory(lib/libpe)
9+
add_subdirectory(lib/libudis86/libudis86)
10+
add_subdirectory(src/plugins)
11+
add_subdirectory(src)
12+
13+

cmake/gcc-static.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# the name of the target operating system
2+
set(CMAKE_SYSTEM_NAME linux-musl)
3+
4+
# which compilers to use for C and C++
5+
set(CMAKE_C_COMPILER gcc)
6+
set(CMAKE_CXX_COMPILER g++)
7+
8+
# where is the target environment located
9+
set(CMAKE_FIND_ROOT_PATH
10+
/home/gogo/src/git.musl-libc.org/musl/lib
11+
/usr
12+
)
13+
14+
# adjust the default behavior of the FIND_XXX() commands:
15+
# search programs in the host environment
16+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
17+
18+
# search headers and libraries in the target environment
19+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
20+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
21+

completion/bash/readpe

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/usr/bin/env bash
2-
complete -F _longopt readpe
2+
3+
function _complete_readpe () {
4+
echo $COMP_LINE
5+
# local _comp=$COMP_LINE
6+
# local _comp=$("${COMP_LINE[@]::${#COMP_LINE[@]}-1} --complete")
7+
local _comp=$($COMP_LINE "--complete")
8+
# printf "headers directories exports"
9+
COMPREPLY=($_comp)
10+
}
11+
12+
complete -F _complete_readpe readpe
313
complete -F _longopt pedis
414
complete -F _longopt pehash
515
complete -F _longopt peldd
@@ -9,3 +19,4 @@ complete -F _longopt pescan
919
complete -F _longopt pesec
1020
complete -F _longopt pestr
1121

22+

doc/readpe-complete.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
prog: "readpe"
2+
help: "Read PE file headers and meta information"
3+
options:
4+
- option_strings: ["-f", "--format"]
5+
metavar: "format"
6+
help: "Set output format"
7+
complete: ["exec", "readpe --get-output-plugins"]
8+
- option_strings: ["--file-version"]
9+
help: "Show PE file version"
10+
final: true
11+
- option_strings: ["-h", "--help"]
12+
help: "Print this message"
13+
final: true
14+
- option_strings: ["--get-output-plugins"]
15+
help: "Print available output plugins"
16+
final: true
17+
18+
---
19+
prog: "readpe header"
20+
help: "Read PE header information"
21+
options:
22+
- option_strings: ["--all"]
23+
positionals:
24+
- number: 1
25+
metavar: "header"
26+
help: "Select a specific header"
27+
complete: ["choices", ["dos", "coff", "optional"]]
28+
29+
---
30+
prog: "readpe section"
31+
help: "Read PE section information"
32+
options:
33+
- option_strings: ["--all"]
34+
35+
---
36+
prog: "readpe directory"
37+
help: "Read PE dorectory information"
38+
options:
39+
- option_strings: ["--list"]
40+
- option_strings: ["--verbose"]
41+
42+
---
43+
prog: "readpe imports"
44+
45+
---
46+
prog: "readpe exports"
47+
48+
---
49+
prog: "readpe resources"
50+
# aliases: ["peres"]
51+
options:
52+
- option_strings: ["--help"]
53+
- option_strings: ["--list"]
54+
- option_strings: ["--verbose"]
55+
- option_strings: ["--tree"]
56+
- option_strings: ["--statistics"]
57+
- option_strings: ["--file-version"]
58+
59+
---
60+
prog: "readpe resources extract"
61+
options:
62+
- option_strings: ["--name"]
63+
64+
---
65+
prog: "readpe scan"
66+
aliases: ["lint"]
67+
# aliases: ["readpe-lint", "pescan"]
68+
options:
69+
- option_strings: ["--verbose"]
70+
71+
---
72+
prog: "readpe libraries"
73+
# aliases: ["peldd"]
74+
75+
---
76+
prog: "readpe features"
77+
aliases: ["security"]
78+
# aliases: ["readpe-security", "pesec"]
79+
80+
---
81+
prog: "readpe certificates"
82+
# aliases: ["pesec"]
83+
options:
84+
- option_strings: ["--out"]
85+
metavar: "certout"
86+
complete: ["file"]
87+
- option_strings: ["--format"]
88+
metavar: "certformat"
89+
complete: ["choices", ["text","x509","pem"]]
90+
91+
---
92+
prog: "readpe hash"
93+
# aliases: ["pehash"]
94+
95+
# TODO:
96+
# Figure out how to do
97+
# readpe section <section_name>|@<section_index> {hash|str}
98+
#
99+
# pehash --section <section_name>
100+
# => readpe section {section_name} hash
101+
# pehash --section_index <section_index>
102+
# => readpe section @<section_index> hash
103+
#
104+
# pestr
105+
# => readpe strings
106+
# pestr --min-length
107+
# => readpe [...] strings --min-length
108+
# pestr --offset
109+
# => readpe [...] strings --offset
110+
# pestr --section
111+
# => readpe section {section_name} strings

0 commit comments

Comments
 (0)