Score:0

How to see the complete 'special symbol set' that apg (Automated Password Generator) is using

jp flag

I am using apg to generate password suggestions, and am using the -M switch to include special keyboard characters:

apg -a 1 -n 1 -m 16 -x 16 -M SNCL
where:
-a, algorithm - 0 default pronounceable, 1 random unpronounceable
-n, number of passwords
-m, minimum length
-x, maximum length
-M, mode - S, Special symbol set, N, Numeral symbol set, C, upper Case symbol set, L, Lower case symbol set

A lot of online services are picky about which special characters can be used, so I want to be able to exclude the ones that are most often not allowed. But in order to do this I need to know what characters apg is using as it's 'special symbol set'. Is there a way of extracting this data from somewhere? Ideally the actual characters not a description if possible, e.g. '%' not 'Percent'

Score:2
hr flag

So far as I can tell, the only way is to refer to the source. The characters for all sets appear to be contained in a single statically initialized array of struct sym:

struct sym smbl[94] = 
{
 {'a', S_SL}, {'b', S_SL}, {'c', S_SL}, {'d', S_SL}, {'e', S_SL}, {'f', S_SL},
 {'g', S_SL}, {'h', S_SL}, {'i', S_SL}, {'j', S_SL}, {'k', S_SL}, {'l', S_SL},
 {'m', S_SL}, {'n', S_SL}, {'o', S_SL}, {'p', S_SL}, {'q', S_SL}, {'r', S_SL},
 {'s', S_SL}, {'t', S_SL}, {'u', S_SL}, {'v', S_SL}, {'w', S_SL}, {'x', S_SL},
 {'y', S_SL}, {'z', S_SL}, {'A', S_CL}, {'B', S_CL}, {'C', S_CL}, {'D', S_CL},
 {'E', S_CL}, {'F', S_CL}, {'G', S_CL}, {'H', S_CL}, {'I', S_CL}, {'J', S_CL},
 {'K', S_CL}, {'L', S_CL}, {'M', S_CL}, {'N', S_CL}, {'O', S_CL}, {'P', S_CL},
 {'Q', S_CL}, {'R', S_CL}, {'S', S_CL}, {'T', S_CL}, {'U', S_CL}, {'V', S_CL},
 {'W', S_CL}, {'X', S_CL}, {'Y', S_CL}, {'Z', S_CL}, {'1', S_NB}, {'2', S_NB},
 {'3', S_NB}, {'4', S_NB}, {'5', S_NB}, {'6', S_NB}, {'7', S_NB}, {'8', S_NB},
 {'9', S_NB}, {'0', S_NB}, {33 , S_SS}, {34 , S_SS}, {35 , S_SS}, {36 , S_SS},
 {37 , S_SS}, {38 , S_SS}, {39 , S_SS}, {40 , S_SS}, {41 , S_SS}, {42 , S_SS},
 {43 , S_SS}, {44 , S_SS}, {45 , S_SS}, {46 , S_SS}, {47 , S_SS}, {58 , S_SS},
 {59 , S_SS}, {60 , S_SS}, {61 , S_SS}, {62 , S_SS}, {63 , S_SS}, {64 , S_SS},
 {91 , S_SS}, {92 , S_SS}, {93 , S_SS}, {94 , S_SS}, {95 , S_SS}, {96 , S_SS},
 {123, S_SS}, {124, S_SS}, {125, S_SS}, {126, S_SS}
};

where

#define S_NB    0x01 /* Numeric */
#define S_SS    0x02 /* Special */
#define S_CL    0x04 /* Capital */
#define S_SL    0x08 /* Small   */
#define S_RS    0x10 /* Restricted Symbol*/

struct sym
 {
  char   ch;
  USHORT type;
 };

So you can write a little bit of C to iterate over the array and print the ch value if the type is equal to S_SS, which gives the following:

! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ 
Broadsworde avatar
jp flag
Thank you kindly, I wasn't expecting that kind of awesome response! Appreciated.
hr flag
@Broadsworde you're welcome - btw, since (according to `apt show apg`) *"apg has not seen upstream attention since 2003"* you might want to look at more actively maintained alternatives like the Perl [String::Random](https://metacpan.org/pod/String::Random) module as well
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.