Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OpenSSL static PIE #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openssl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/openssl-3.0.5/
/openssl-3.0.5.tar.gz*
28 changes: 28 additions & 0 deletions openssl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build OpenSSL as static PIE

Script to build OpenSSL as a static PIE ELF binary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Script to build OpenSSL as a static PIE ELF binary.
Script to build OpenSSL as a static PIE ELF binary.


## Requirements

Make sure that you have the following packages:
* GCC
* GNU Make

## Build

Run the build.sh file.
It will create a folder where the static PIE OpenSSL will be located.

## Running

### Encrypt

```bash
./openssl aes-256-cbc -a -salt -pbkdf2 -pass pass:PASSWORD -in rootfs/plaintext.txt -out rootfs/ciphertext.enc
```

### Decrypt

```bash
./openssl aes-256-cbc -d -a -salt -pbkdf2 -pass pass:PASSWORD -in rootfs/ciphertext.enc
```
28 changes: 28 additions & 0 deletions openssl/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

SSL_URL="https://www.openssl.org/source/openssl-3.0.5.tar.gz"
rm -rf SSL-*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a cleanup step here.
The rm -rf SSL-* command does not do anything since there is nothing in the current directory to match that name.
It should remove the extracted source code, see nginx as an example.

echo -n "Downloading OpenSSL ... "
wget -q "$SSL_URL"
echo ""

echo -n "Unpacking OpenSSL ... "
tar xzf openssl-3.0.5.tar.gz
echo ""

pushd openssl-3.0.5 > /dev/null 2>&1 || exit 1

echo -n "Configuring OpenSSL for static-PIE building..."
./Configure -static
echo ""

echo "Building OpenSSL..."
sed -i "0,/$(BIN_LDFLAGS)/{s/$(BIN_LDFLAGS)[^ ]*/-static-pie/}" Makefile
make -j "$(nproc)"
echo ""

popd > /dev/null 2>&1 || exit 1

ln -fn openssl-3.0.5/apps/openssl .

rm openssl-3.0.5.tar.gz*
Binary file added openssl/openssl
Binary file not shown.
1 change: 1 addition & 0 deletions openssl/rootfs/ciphertext.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
U2FsdGVkX189ngaVPb5krYDlQl7EaJSOs3fx7C+zC+4=
1 change: 1 addition & 0 deletions openssl/rootfs/plaintext.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abcdefgh