Skip to content

Commit

Permalink
Add OpenSSL static PIE
Browse files Browse the repository at this point in the history
Signed-off-by: Giulia <iuliastefania.sandulescu@yahoo.com>
  • Loading branch information
Giulia424 committed Oct 22, 2022
1 parent 5974451 commit 5499e4d
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 0 deletions.
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*
33 changes: 33 additions & 0 deletions OpenSSL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Build OpenSSL as static PIE

Script to build OpenSSL as a static PIE binary for use with Unikraft


## 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
```


33 changes: 33 additions & 0 deletions OpenSSL/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

SSL_URL="https://www.openssl.org/source/openssl-3.0.5.tar.gz"
rm -rf SSL-*
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
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.

## 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-*
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

0 comments on commit 5499e4d

Please sign in to comment.