2024-08-28 02:05:27 +02:00
# checkpw
2024-08-10 06:03:34 +02:00
2024-09-24 04:48:06 +02:00
checkpw is a program that checks the validity of a users password on a UNIX/PAM-based system.
2024-08-10 06:08:41 +02:00
2024-12-12 00:20:22 +01:00
Currently only tested on Linux, but it should work on the [AIX ](https://en.wikipedia.org/wiki/IBM_AIX ), [DragonFly BSD ](https://www.dragonflybsd.org/ ), [FreeBSD ](https://www.freebsd.org/ ), [HP-UX ](https://en.wikipedia.org/wiki/HP-UX ), [Linux ](https://kernel.org/ ), [macOS ](https://en.wikipedia.org/wiki/MacOS ), [NetBSD ](https://netbsd.org/ ) and [Solaris ](https://en.wikipedia.org/wiki/Oracle_Solaris ) operating system too.
2024-09-25 23:09:41 +02:00
2025-01-01 06:23:03 +01:00
## The idea
2024-08-10 23:38:07 +02:00
2025-01-01 06:23:03 +01:00
I needed a program to verify passwords of users on Linux/UNIX systems using PAM that just return 0 on success and 1 on error.
2024-08-17 23:07:57 +02:00
2025-01-01 06:23:03 +01:00
## Building checkpw
2024-08-17 23:07:57 +02:00
2024-08-10 23:38:07 +02:00
```
2024-08-28 02:24:15 +02:00
git clone https://git.xw3.org/xw3/checkpw.git
2024-08-10 23:38:07 +02:00
cd checkpw
make
```
2025-01-01 06:23:03 +01:00
The code only supports verifying passwords for user id 1000 by default. Look at the file checkpw.h for some compile time options!
2024-08-17 23:07:57 +02:00
2025-01-01 06:23:03 +01:00
### Custom build example
2024-08-28 18:16:59 +02:00
2025-01-01 06:23:03 +01:00
Set MAX_UID and MIN_UID at compile time:
2024-08-17 23:07:57 +02:00
```
2024-08-28 18:18:57 +02:00
gcc -Wall -DMAX_UID=1000 -DMIN_UID=1000 -o checkpw checkpw.c -lpam -lpam_misc
2024-08-17 23:07:57 +02:00
```
2025-01-01 06:23:03 +01:00
## Installation
**WARNING:** Install this software with care. checkpw could easily be used for bruteforcing passwords from local users!
```
sudo make install
```
checkpw is installed to /usr/bin/.
checkpw.h is installed to /usr/include/ for use in other applications.
## Uninstall
2024-08-27 20:27:17 +02:00
```
sudo make uninstall
```
2025-01-01 06:23:03 +01:00
## Usage
2024-08-10 15:55:11 +02:00
```
2024-08-17 23:22:21 +02:00
checkpw -h
2025-01-01 06:23:03 +01:00
Usage: checkpw [-u <username>] [-p <password>] [-v] [-V] [-h]
2024-08-10 15:52:47 +02:00
Options:
-u <username> Specify username.
-p <password> Specify password.
-v Enable verbose mode.
2025-01-01 06:23:03 +01:00
-V Print program version.
2024-08-18 01:02:34 +02:00
-h Show this help.
2024-08-10 15:52:47 +02:00
```
2025-01-01 06:23:03 +01:00
You can also use checkpw even without installing by just running the following command:
2024-08-18 02:03:29 +02:00
```
2025-01-01 06:23:03 +01:00
./checkpk
2024-08-18 02:03:29 +02:00
```
2025-01-01 06:23:03 +01:00
checkpw returns 0 on success, 1 otherwise.
### Examples
#### Interactive mode asking for a username and a password
2024-08-18 02:03:29 +02:00
```
2025-01-01 06:23:03 +01:00
checkpw
2024-08-18 02:03:29 +02:00
```
2025-01-01 06:23:03 +01:00
#### Interactive mode only asking for a password
```
checkpw -u hanez
```
#### None interactive mode with username and password provided as arguments to checkpw
2024-08-18 02:03:29 +02:00
```
checkpw -u hanez -p password
```
2025-01-01 06:23:03 +01:00
#### Request the result from the above commands
2024-08-18 02:03:29 +02:00
2024-08-10 15:54:14 +02:00
```
echo $?
```
2024-08-10 22:12:47 +02:00
2025-01-01 06:43:23 +01:00
## License
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2025-01-01 06:23:03 +01:00
## Links
2024-08-20 17:52:42 +02:00
2025-01-01 06:43:23 +01:00
- [Homepage of checkpw ](https://git.xw3.org/xw3/checkpw )
2024-08-20 17:52:42 +02:00
- [https://cr.yp.to/checkpwd.html ](https://cr.yp.to/checkpwd.html )
2024-08-27 21:04:25 +02:00
- [https://pamtester.sourceforge.net/ ](https://pamtester.sourceforge.net/ )
2024-08-20 17:52:42 +02:00