chkusr/README.md

150 lines
4.3 KiB
Markdown
Raw Normal View History

# MERGED PROJECT!!! I WILL UPDATE THIS README IN THE NEXT DAYS!!! THE FOLLOWING DOCUMENTATION WILL NOT WORK ACTUALLY!
# chkusr
chkusr is a set of programs to verify information about a user on a UNIX based systems.
2025-06-27 01:30:22 +02:00
* [The idea](#the-idea)
* [Requirements](#requirements)
* [Building chkusr](#building-chkusr)
* [Installation](#installation)
* [Uninstall](#uninstall)
* [chkgrp](#chkgrp)
* [chkpwd](#chkpwd)
* [Custom build](#custom-build)
* [Usage](#usage)
* [Return codes](#return-codes)
* [Examples](#examples)
* [Interactive mode asking for a username and a password](#interactive-mode-asking-for-a-username-and-a-password)
* [Interactive mode only asking for a password](#interactive-mode-only-asking-for-a-password)
* [None interactive mode with username and password provided as arguments to chkpwd](#none-interactive-mode-with-username-and-password-provided-as-arguments-to-chkpwd)
* [Request the result from the above commands](#request-the-result-from-the-above-commands)
* [Links](#links)
* [License](#license)
2025-06-27 01:09:31 +02:00
## The idea
2025-06-27 01:09:31 +02:00
I needed some programs to verify some information about users and groups on a Linux/UNIX system just returning 0 on success and 1 on error.
2024-08-10 06:08:41 +02:00
2025-06-04 18:43:26 +02:00
Currently chkpwd is only tested on Linux, but it should work on a [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
### Requirements
2025-05-30 04:17:15 +02:00
You need the PAM development package installed. On Alpine it is named linux-pam-dev, on Debian based systems it is libpam0g-dev.
2025-06-27 01:09:31 +02:00
### Building chkusr
2024-08-17 23:07:57 +02:00
2024-08-10 23:38:07 +02:00
```
2025-06-27 01:09:31 +02:00
git clone https://git.xw3.org/hanez/chkusr.git
cd chkusr
2024-08-10 23:38:07 +02:00
make
```
### Installation
2025-06-04 18:43:26 +02:00
**WARNING:** Install this software with care. chkpwd could easily be used for bruteforcing passwords from local users!
```
sudo make install
```
2025-06-27 01:09:31 +02:00
chkusr programs are installed to /usr/bin/.
2025-06-04 18:43:26 +02:00
chkpwd.h is installed to /usr/include/ for use in other applications.
### Uninstall
```
sudo make uninstall
```
2025-06-27 01:09:31 +02:00
## chkgrp
chkgrp is a program to verify if a user is a member of a group.
More information will follow... Actually there are multiple programs with some different behavior. I will write more about this, but for now I will not.
## chkpwd
chkpwd is a program that checks the validity of a users password on a UNIX/[PAM](https://en.wikipedia.org/wiki/Pluggable_Authentication_Module)-based system.
The code only supports verifying passwords for user id 1000 by default. Look at the file chkpwd.h for some compile time options!
#### Custom build
Set MAX_UID and MIN_UID at compile time:
```
gcc -Wall -DMAX_UID=1000 -DMIN_UID=1000 -o chkpwd chkpwd.c -lpam -lpam_misc
```
### Usage
2024-08-10 15:55:11 +02:00
```
2025-06-04 18:43:26 +02:00
chkpwd -h
Usage: chkpwd [-u <username>] [-p <password>] [-v] [-V] [-h]
2024-08-10 15:52:47 +02:00
Options:
2025-01-01 07:19:45 +01:00
-u <username> Set username.
-p <password> Set password.
2024-08-10 15:52:47 +02:00
-v Enable verbose mode.
-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-06-04 18:43:26 +02:00
You can also use chkpwd even without installing by just running the following command:
2024-08-18 02:03:29 +02:00
```
2025-06-04 18:43:26 +02:00
./chkpwd
2024-08-18 02:03:29 +02:00
```
#### Return codes
2025-01-11 04:42:45 +01:00
2025-06-27 01:09:31 +02:00
chk 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-06-04 18:43:26 +02:00
chkpwd
2024-08-18 02:03:29 +02:00
```
##### Interactive mode only asking for a password
```
2025-06-04 18:43:26 +02:00
chkpwd -u hanez
```
##### None interactive mode with username and password provided as arguments to chkpwd
2024-08-18 02:03:29 +02:00
```
2025-06-04 18:43:26 +02:00
chkpwd -u hanez -p password
2024-08-18 02:03:29 +02: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-06-27 01:09:31 +02:00
## Links
2024-08-20 17:52:42 +02:00
2025-06-04 18:43:26 +02:00
- [https://git.xw3.org/hanez/chkpwd](https://git.xw3.org/hanez/chkpwd)
- [https://www.man7.org/linux/man-pages/man8/unix_chkpwd.8.html](https://www.man7.org/linux/man-pages/man8/unix_chkpwd.8.html)
2024-08-20 17:52:42 +02:00
- [https://cr.yp.to/checkpwd.html](https://cr.yp.to/checkpwd.html)
- [https://pamtester.sourceforge.net/](https://pamtester.sourceforge.net/)
2025-06-05 04:23:43 +02:00
- [https://github.com/AlexanderZhirov/chkpass](https://github.com/AlexanderZhirov/chkpass)
- [https://github.com/ViKingIX/pam_test](https://github.com/ViKingIX/pam_test)
- [https://github.com/Dareka826/chk_pw](https://github.com/Dareka826/chk_pw)
2024-08-20 17:52:42 +02:00
## License
chkpwd is licensed under the Apache License, Version 2.0.
See LICENSE for details.