Kernel module which generates random /proc/flag files
$ dmesg -wH &
$ clear
$ sudo insmod kflags.ko
$ [Mar29 18:17] Loaded /proc/flag module
[Mar29 18:17] Loaded /proc/flag module
cat /proc/flag
8A3F8F79DE292929356DB5DD0E246EE9AE806E6573138E685DFCFF8E91ABF19E
E5836EC868E4E3DFDC891B9B58B16CDCF8F9641A26ADEE0CF5CD324A38612495
4328BA9861FE8534D4A7B2B131DCE336E186C7ADA5530E1FB8101039248C6F6E
1E553731E1DF5F79552B03883EC83E6EE2BD1F750A5F8DF251467FD124361F0A
FA613941F92E874D1F25451117DDB58795FF73BA2B84FC4CCAE984F5B1BD0751
BA1FABE1804724CBA87B4847B266FA4CB9FA7F395A7DD3E8438B753917DAF95F
BC3757F8C52372DD23CFD992677F23637547C939A6455E2F66A96532C7CD91AF
5FC941C9C8B3F59F2A9382AB6061CF56007AFAC08B228004325E9BDA7C1D4223
EFFB62295B1A1C9BE2CF23E602A7B9ADEB812F61FAD2BD6F74F3C3B82961E7CB
DA18A4291929E4F44AC4DFDF63688E1D4B6CB3B18B5E790DF828ECD962FBD210
E728D63BF77872E6EB805BE63BA1FA1D2E7267DF01E6D114B67DEB1F38362686
BBDEC3DDCA8AAD31DC5A232AF4B1F975AFD6F7B5D3E5F87309FCB34CDADBA71A
C367235C77E17CE75ED72004F66D5606F08D0FEFC02C944A8DA8EBCE7C767E96
0ECE283F3C16031ED353F72B5C36D2C19A3EFAA09C7AC11EA22E5EA4BE3F3027
BE8504108C971D7CD22BE74ADEB72097F4CEA5EB2AD00C5E4AEBF2CB84D077EB
BD7D2404ECF01E569E78425EFBD3D42DAD20674C74A18F1F64D0FD1D29CB5EF9
$ cat /proc/flag
7FAE389A1A4F2E3CC973DC37B64BBB6A357E93D18568627E57EA3EA980E885B6
413D640EEB1CA3000D291E9A7D1E9467D5E0AD61853E8AF9344FD49E8663F0E6
6E4C018D471E0F209CE3BDFDFD5D13442FE652F372593576A65FEF8596DAC747
B8CC182823A5DD3C9A8885D100A290BE4ADC9E9A5E3D4C4732944E2C150A9345
698614C3CD6F50752FCD9E76D3C0BDF1E21676D59ABAC59404B178D3068FDA4B
E2261E819D1F13972052609B4697B709DC113B20F9816809265DAAFBD71019DA
7F703562D7B9312A5D525359B59676B8A7C883D9EAF41DD2A721A9D50F441622
55D0C036E077DBD37595FF5D30D097B11AA82E3E5FE954F5CE7EA74AAFC1B81A
007AD602DB3C0E7C50EE4DE41E70B46EA7389F51BDCF68796031845883351469
28A31132578F88460D9AA7AFB721D247D213A4682DD5B42BD9AD9FB4E4B01EEB
F355682D350C071D804DE8E84EC11E2DFDFAABAC30D5C1A9173A8B35E746F885
921AB3C995C598B8980B53BA652481B3BE95C249DB56E2EFDC8B95CF3BD5E05E
97787FD0C63797BBD83D1C0D5AC8323106222387B41DEC5048E45977767739CE
298E62247649CBAB87921A43C971542E005D4FA7F092B7BA6216E2BB88D98170
A06CCD8CCDB9E18E3C7F9DEB02EF14D99EEB45CED88B50737A410E1628985087
D48B67048A72222E2B05977AFE8DC857C52C7C20D23577EFBB707C518BBB31E5
$ sudo rmmod kflags.ko
[ +18.618607] Unloaded /proc/flag module
[ +18.618607] Unloaded /proc/flag module
$ cat /proc/flag
cat: /proc/flag: No such file or directory
The included makefile will build the kernel module and load it with insmod
. You must have root access and will be prompted for your password if necessary.
$ make
make -C /lib/modules/4.15.0-20-generic/build M=/mnt/hgfs/6265-info-sec-lab/kflags modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-20-generic'
Makefile:976: "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel"
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-20-generic'
sudo rmmod kflags.ko || true
rmmod: ERROR: Module kflags is not currently loaded
sudo insmod kflags.ko
[Mar29 18:20] Loaded /proc/flag module
[Mar29 18:20] Loaded /proc/flag module
By default, the module will load /proc/flag
, and generate random flags of size 1024.
- To change
/proc/flag
into/proc/other
, modify#define PROC_NAME
- To change flag size, modify
#define FLAG_SIZE