• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H24-Oct-2021-258217

.idea/H24-Oct-2021-154154

buildfiles/H24-Oct-2021-7253

chars/H24-Oct-2021-8862

cmd/apg/H24-Oct-2021-436381

config/H24-Oct-2021-195161

example-code/simple-password-generator/H24-Oct-2021-2825

random/H24-Oct-2021-8169

spelling/H24-Oct-2021-141127

vendor/github.com/wneessen/go-hibp/H03-May-2022-1,3211,011

.cirrus.ymlH A D24-Oct-2021591 2420

.gitignoreH A D24-Oct-2021287 2016

CODE_OF_CONDUCT.mdH A D24-Oct-20215.1 KiB12993

LICENSEH A D24-Oct-20211 KiB2217

README.mdH A D24-Oct-202112.5 KiB258232

SECURITY.mdH A D24-Oct-2021284 74

go.modH A D24-Oct-202187 63

go.sumH A D24-Oct-2021173 32

README.md

1# A "Automated Password Generator"-clone
2[![Go Reference](https://pkg.go.dev/badge/github.com/wneessen/apg-go.svg)](https://pkg.go.dev/github.com/wneessen/apg-go) [![Go Report Card](https://goreportcard.com/badge/github.com/wneessen/apg-go)](https://goreportcard.com/report/github.com/wneessen/apg-go) [![Build Status](https://api.cirrus-ci.com/github/wneessen/apg-go.svg)](https://cirrus-ci.com/github/wneessen/apg-go) ![CodeQL workflow](https://github.com/wneessen/apg-go/actions/workflows/codeql-analysis.yml/badge.svg) <a href="https://ko-fi.com/D1D24V9IX"><img src="https://uploads-ssl.webflow.com/5c14e387dab576fe667689cf/5cbed8a4ae2b88347c06c923_BuyMeACoffee_blue.png" height="20" alt="buy ma a coffee"></a>
3
4_apg-go_ is a simple APG-like password generator written in Go. It tries to replicate the
5functionality of the
6"[Automated Password Generator](https://web.archive.org/web/20130313042424/http://www.adel.nursat.kz:80/apg)",
7which hasn't been maintained since 2003. Since more and more Unix distributions are abondoning the tool, I was
8looking for an alternative. FreeBSD for example recommends "security/makepasswd", which is written in Perl
9but requires a lot of dependency packages and doesn't offer the feature-set/flexibility of APG.
10
11Since FIPS-181 (pronouncable passwords) has been withdrawn in 2015, apg-go does not follow this standard. Instead
12it implements the [Koremutake Syllables System](https://shorl.com/koremutake.php) in its pronouncable password mode.
13
14## Installation
15### Ports/Packages
16#### FreeBSD
17apg-go can be found as `/security/apg` in the [FreeBSD ports](https://cgit.freebsd.org/ports/tree/security/apg)
18tree.
19#### Arch Linux
20Find apg-go in [Arch Linux AUR](https://aur.archlinux.org/packages/apg-go/). \
21Alternatively use the [PKGBUILD](https://github.com/wneessen/apg-go/tree/main/buildfiles/arch-linux) file
22in this git repository
23### Binary releases
24#### Linux/BSD/MacOS
25* Download release
26  ```sh
27  $ curl -LO https://github.com/wneessen/apg-go/releases/download/v<version>/apg-v<version>-<os>-<architecture>.tar.gz
28  $ curl -LO https://github.com/wneessen/apg-go/releases/download/v<version>/apg-v<version>-<os>-<architecture>.tar.gz.sha256
29  ```
30* Verify the checksum
31  ```sh
32  $ sha256 apg-v<version>-<os>-<architecture>.tar.gz
33  $ cat apg-v<version>-<os>-<architecture>.tar.gz.sha256
34  ```
35  **Make sure the checksum of the downloaded file and the checksum in the .sha256 match**
36* Extract archive
37  ```sh
38  $ tar xzf apg-v<version>-<os>-<architecture>.tar.gz
39  ```
40* Execute
41  ```sh
42  $ ./apg
43  ```
44#### Windows
45* Download release
46  ```PowerShell
47  PS> Invoke-RestMethod -Uri https://github.com/wneessen/apg-go/releases/download/v<version>/apg-v<version>-windows-<architecture>.zip -OutFile apg-v<version>-windows-<architecure>.zip
48  PS> Invoke-RestMethod -Uri https://github.com/wneessen/apg-go/releases/download/v<version>/apg-v<version>-windows-<architecture>.zip.sha256 -OutFile apg-v<version>-windows-<architecure>.zip.sha256
49  ```
50* Verify the checksum
51  ```PowerShell
52  PS> Get-FileHash apg-v<version>-windows-<architecture>.zip | Format-List
53  PS> type apg-v<version>-windows-<architecture>.zip.sha256
54  ```
55  **Make sure the checksum of the downloaded file and the checksum in the .sha256 match**
56* Extract archive
57  ```PowerShell
58  PS> Expand-Archive -LiteralPath apg-v<version>-windows-<architecture>
59  ```
60* Execute
61  ```PowerShell
62  PS> cd apg-v<version>-windows-<architecture>
63  PS> apg.exe
64  ```
65
66### Sources
67* Download sources
68  ```sh
69  $ curl -LO https://github.com/wneessen/apg-go/archive/refs/tags/v<version>.tar.gz
70  ```
71* Extract source
72  ```sh
73  $ tar xzf v<version>.tar.gz
74  ```
75* Build binary
76  ```sh
77  $ cd apg-go-<version>
78  $ go build -o apg ./...
79  ```
80* Execute the brand new binary
81  ```sh
82  $ ./apg
83  ```
84
85### Systemwide installation
86It is recommed to install apg in a directory of your ```$PATH``` environment. To do so run:
87(In this example we use ```/usr/local/bin``` as system-wide binary path. YMMV)
88```sh
89$ sudo cp apg /usr/local/bin/apg
90```
91
92## Programmatic interface
93Since v0.4.0 the CLI and the main package functionality have been separated from each other, which makes
94it easier to use the `apg-go` package in other Go code as well. This way you can make of the password
95generation in your own code without having to rely on the actual apg-go binary.
96
97Code examples on how to use the package can be found in the [example-code](example-code) directory.
98
99## Usage examples
100### Default behaviour
101By default apg-go will generate 6 passwords, with a minimum length of 12 characters and a
102maxiumum length of 20 characters. The generated password will use a character set constructed
103from lower case, upper case and numeric characters.
104```shell
105$ ./apg-go
106R8rCC8bw5NvJmTUK2g
107cHB9qogTbfdzFgnH
108hoHfpWAHHSNa4Q
109QyjscIsZkQGh
110904YqsU5SnoqLo2w
111utdFKXdeiXFzM
112```
113### Modifying the character sets
114#### Old style
115Let's assume you want to generate a single password, constructed out of upper case, numeric
116and special characters. Since lower case is part of the default set, you would need to disable them
117by setting the `-L` parameter. In addition you would set the `-S` parameter to enable special
118characters. Finally the parameter `-n 1` is needed to keep apg-go from generating more than one
119password:
120```shell
121$ ./apg-go -n 1 -L -S
122XY7>}H@5U40&_A1*9I$
123```
124
125#### New/modern style
126Since the old style switches can be kind of confusing, it is recommended to use the "new style"
127parameters instead. The new style is all combined in the `-M` parameter. Using the upper case
128version of a parameter argument enables a feature, while the lower case version disabled it. The
129previous example could be represented like this in new style:
130```shell
131$ ./apg-go -n 1 -M lUSN
132$</K?*|M)%8\U$5JA5~
133```
134
135#### Human readability
136Generated passwords can sometimes be a bit hard to read for humans, especially when ambiguous
137characters are part of the password. Some characters in the ASCII character set look similar to
138each other. In example it can be hard to differentiate an upper case I from a lower case l.
139Same applies to the number zero (0) and the upper case O. To not run into issues with human
140readability, you can set the `-H` parameter to toggle on the "human readable" feature. When the
141option is set, apg-go will avoid using any of the typical ambiguous characters in the generated
142passwords.
143```shell
144$ ./apg-go -n 1 -M LUSN -H
145YpranThY3b6b5%\6ARx
146```
147
148#### Character exclusion
149Let's assume, that for whatever reason, your generated password can never include a colon (:) sign. For
150this specific case, you can use the `-E` parameter to specify a list of characters that are to be excluded
151from the password generation character set:
152```shell
153$ ./apg-go -n 1 -M lUSN -H -E :
154~B2\%E_|\VV|/5C7EF=
155```
156
157#### Complex passwords
158If you want to generate complex passwords, there is a shortcut for this as well. By setting the `-C`
159parameter, apg-go will automatically default to the most secure settings. The complex parameter
160basically implies that the password will use all available characters (lower case, upper case,
161numeric and special) and will make sure that human readability is disabled.
162```shell
163$ ./apg-go -n 1 -C
164{q6cvz9le5_fo"X7
165```
166
167### Password length
168By default, apg-go will generate a password with a random length between 12 and 20 characters. If you
169want to be more specific, you can use the `-m` and `-x` parameters to override the defaults. Let's
170assume you want a single complex password with a length of exactly 32 characters, you can do so by
171running:
172```shell
173$ ./apg-go -n 1 -C -m 32 -x 32
1745lc&HBvx=!EUY*;'/t&>B|~sudhtyDBu
175```
176
177### Password spelling
178If you need to read out a password, it can be helpful to know the corresponding word for that character in
179the phonetic alphabet. By setting the `-l` parameter, agp-go will provide you with the phonetic spelling
180(english language) of your newly created password:
181```shell
182$ ./apg-go -n 1 -M LUSN -H -E : -l
183fUTDKeFsU+zn3r= (foxtrot/Uniform/Tango/Delta/Kilo/echo/Foxtrot/sierra/Uniform/PLUS_SIGN/zulu/november/THREE/romeo/EQUAL_SIGN)
184```
185
186### Pronouncable passwords
187Since v0.4.0 apg-go supports pronouncable passwords, anologous to the original c-apg using the `-a 0`
188flag. The original c-apg implemented FIPS-181, which was withdrawn in 2015 for generating pronouncable
189passwords. Since the standard is not recommended anymore, `apg-go` instead make use of the
190[Koremutake Syllables System](https://shorl.com/koremutake.php). Similar to the original apg, `agp-go`
191will automatically randomly add special characters and number (from the human-readable pool) to each
192generated pronouncable password. Additionally it will perform a "coinflip" for each Koremutake syllable
193and decided if it should switch the case of one of the characters to an upper-case character.
194
195Using the `-t` parameter, `apg-go` will display a spelled out version of the pronouncable password, where
196each syllable or number/special character is seperated with a "-" (dash) and if the syllable is not a
197Koremutake syllable the character will be spelled out the same was as with activated `-l` in the
198non-pronouncable password mode (`-a 1`).
199
200**Note on password length**: The `-m` and `-x` parameters will work in prouncable password mode, but
201please keep in mind, that due to the nature how syllables work, your generated password might exceed
202the desired length by one complete syllable (which can be up to 3 characters long).
203
204**Security consideration:** Please keep in mind, that pronouncable passwords are less secure then truly
205randomly created passwords, due to the nature how syllables work. As a rule of thumb, it is recommended
206to multiply the length of your generated pronouncable passwords by at least 1.5 times, compared to truly
207randomly generated passwords. It might also be helpful to run the pronoucable password mode with enabled
208"[HIBP](#have-i-been-pwned)" flag, so that each generated password is automatically checked against "Have I Been Pwned"
209database.
210```shell
211$ ./apg-go -a 0 -n 1
212KebrutinernMy
213
214$ ./apg-go -a 0 -n 1 -m 15 -x 15 -t
215pEnbocydrageT*En (pEn-bo-cy-dra-geT-ASTERISK-En)
216```
217
218### Have I Been Pwned
219Even though, the passwords that apg-go generated for you, are secure, there is a minimal chance, that
220someone on the planet used exactly the same password before and that this person was part of an
221internet leak or hack, which exposed the password to the public. Such passwords are not considered
222secure anymore as they usually land on public available password lists, that are used by crackers.
223
224To be on the safe side, you can use the `-p` parameter, to enable a HIBP check. When the feature is
225enabled, apg-go will check the HIBP database at https://haveibeenpwned.com if that password has been
226leaked before and provide you with a warning if that is the case.
227
228Please be aware, that this is a live check against the HIBP API, which not only requires internet
229connectivity, but also might take between 500ms to 1s to complete. When you generating a bigger list
230of password `-n 100`, the process could take much longer than without the `-p` feature enabled.
231
232## CLI parameters
233_apg-go_ replicates most of the parameters of the original c-apg. Some parameters are different though:
234
235- `-a <algorithm>`: Choose password generation algorithm (Default: 1)
236  - `0`: Pronouncable password generation (Koremutake syllables)
237  - `1`: Random password generation according to password modes/flags
238- `-m <length>`: The minimum length of the password to be generated (Default: 12)
239- `-x <length>`: The maximum length of the password to be generated (Default: 20)
240- `-n <number of passwords>`: The amount of passwords to be generated (Default: 6)
241- `-E <list of characters>`: Do not use the specified characters in generated passwords
242- `-M <[LUNSHClunshc]>`: New style password parameters (upper-case enables, lower-case disables)
243- `-L`: Use lower-case characters in passwords (Default: on)
244- `-U`: Use upper-case characters in passwords (Default: on)
245- `-N`: Use numeric characters in passwords (Default: on)
246- `-S`: Use special characters in passwords (Default: off)
247- `-H`: Avoid ambiguous characters in passwords (i. e.: 1, l, I, o, O, 0) (Default: off)
248- `-C`: Generate complex passwords (implies -L -U -N -S and disables -H) (Default: off)
249- `-l`: Spell generated passwords in random password mode (Default: off)
250- `-t`: Spell generated passwords in pronouncable password mode (Default: off)
251- `-p`: Check the HIBP database if the generated passwords was found in a leak before (Default: off) // *this feature requires internet connectivity*
252- `-h`: Show a CLI help text
253- `-v`: Show the version number
254
255## Contributors
256Thanks to the following people for contributing to the apg-go codebase:
257* [Romain Tartière](https://github.com/smortex)
258