File tree Expand file tree Collapse file tree 11 files changed +8491
-0
lines changed
.bin/etc-files-list-update Expand file tree Collapse file tree 11 files changed +8491
-0
lines changed Original file line number Diff line number Diff line change 1+ # Etc File List Updater
2+
3+ ## Overview
4+ The purpose of this set of scripts is to update the file ` Fuzzing/LFI/LFI-etc-files-of-all-linux-packages.txt ` .
5+ It is intended to be run periodically.
6+ The scripts scan all deb packages in the ubuntu apt repository that have been updated since the last scan.
7+ URLs that have been scanned will be added to a data file that can be stored in git.
8+
9+ ## Running
10+ The script must be run from its working directory.
11+ ``` bash
12+ cd .bin/etc-files-list-update && ./update.sh
13+ ```
14+
15+ ## Details
16+ URLs for deb files that have already been scanned are stored in gzip format in the ` deb-url-history/ ` directory.
17+ The current ubuntu distro for which packages are retrieved is stored in the file ` current_distro ` . This should be changed every few years.
Original file line number Diff line number Diff line change 1+ kinetic
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ export listpath=" ../../Fuzzing/LFI/LFI-etc-files-of-all-linux-packages.txt"
4+ [ -f all_files.gz ] && rm all_files.gz
5+
6+ # every year, start a new gzip list so there is not as much bloat updating blobs in git
7+ year=$( date +%Y)
8+
9+ echo " finding URLs" 1>&2
10+
11+ # get new URLs
12+ util/find-new-urls.awk > url_batch
13+
14+ # exit if there's no new URLs to scan
15+ if [[ $( wc -l url_batch | awk ' {print $1}' ) == 0 ]]
16+ then
17+ echo " no new URLs" 1>&2
18+ rm url_batch
19+ exit 0
20+ fi
21+
22+ # scan them
23+ for u in $( cat url_batch)
24+ do
25+ echo " scanning $u " 1>&2
26+ util/scan-package.sh " $u " | gzip >> all_files.gz
27+ done
28+
29+ echo " searching for etc files" 1>&2
30+
31+ # get all files matching /etc/
32+ # ignore repeat files already in the list
33+ zcat all_files.gz | awk '
34+ BEGIN {
35+ lp = ENVIRON["listpath"]
36+ while (getline < lp) {
37+ seen[$0] = 1
38+ }
39+ }
40+ /^\/etc\// && !seen[$0] { print }
41+ ' > updated_etc_files
42+
43+ echo " updating list" 1>&2
44+
45+ # concatenate the existing list and the output
46+ cat " $listpath " updated_etc_files > updated_file
47+
48+ # update the list
49+ mv updated_file " $listpath "
50+
51+ # save progress
52+ cat url_batch | gzip >> " deb-url-history/$year .gz"
53+
54+ # cleanup
55+ rm url_batch
56+ rm updated_etc_files
57+ rm all_files.gz
Original file line number Diff line number Diff line change 1+ #!/usr/bin/awk -f
2+ BEGIN {
3+ # load all the URLs we scanned already
4+ command = " util/print-urls.sh"
5+ while (command | getline ) {
6+ urls[ $0 ] = 1 # add to set
7+ }
8+ close (command)
9+ # get package URLs that do not appear in the list
10+ command = " util/get-package-urls.sh"
11+ while (command | getline ) {
12+ if (! ($0 in urls)) print
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # get new package URLs
4+ # load the list of amd64 packages from ubuntu
5+ export dist=" $( cat current_distro) "
6+ export repo=" http://archive.ubuntu.com/ubuntu"
7+
8+ # print URLs
9+ curl $repo /dists/$dist /main/binary-amd64/Packages.gz | \
10+ gzip -d | awk ' /^Filename: / { print ENVIRON["repo"] "/" $2 }'
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # print every url in every file in deb-url-history directory
4+ for f in $( ls deb-url-history/)
5+ do
6+ zcat " deb-url-history/$f "
7+ done
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ export url=$1
4+
5+ tf=$( mktemp -d)
6+ wd=$( pwd)
7+ cd $tf
8+ wget " $url " -O output 2> /dev/null > /dev/null
9+ ar -x output # extracts data.tar.xz control.tar.xz
10+
11+ # extract tar
12+ if [ -f control.tar.xz ]; then
13+ xz -d control.tar.xz 2> /dev/null
14+ elif [ -f control.tar.zst ]; then # need to install zstd
15+ zstd -d control.tar.zst 2> /dev/null
16+ elif [ -f control.tar.gz ]; then
17+ tar -xzvf control.tar.gz 2> /dev/null > /dev/null
18+ else
19+ (echo " $url unknown deb compression format" && ls) >> problems
20+ exit 0
21+ fi
22+
23+ # extract control
24+ tar -xvf control.tar 2> /dev/null > /dev/null
25+
26+ # replace 2 spaces after md5sum with tab
27+ sed ' s/^\([0-9a-zA-Z]*\) /\1\t/' md5sums > inputdata
28+
29+ # print filenames
30+ awk '
31+ BEGIN {
32+ FS="\t"
33+ }
34+ {
35+ gsub(/^\.\//,"",$2)
36+ print "/" $2
37+ }
38+ ' inputdata
39+
40+ # cleanup
41+ cd " $wd "
42+ rm -rf $tf
Original file line number Diff line number Diff line change 1+ name : update etc files
2+
3+ # Controls when the workflow will run
4+ on :
5+ schedule :
6+ - cron : ' 30 20 1,15 * *' # run at 8:30p on 1st and 15th
7+
8+ # Allows you to run this workflow manually from the Actions tab
9+ workflow_dispatch :
10+
11+ jobs :
12+ updatejob :
13+ # The type of runner that the job will run on
14+ runs-on : ubuntu-latest
15+ # Steps represent a sequence of tasks that will be executed as part of the job
16+ steps :
17+ - uses : actions/checkout@v3
18+
19+ # Runs a single command using the runners shell
20+ - name : update wordlist
21+ run : cd .bin/etc-files-list-update/ && ./update.sh
22+
23+ - name : print diff
24+ run : git diff
25+
26+ # commit and push
27+ - uses : stefanzweifel/git-auto-commit-action@v4
28+ with :
29+ commit_message : ' [Github Action] Updated LFI-etc-files-of-all-linux-packages.txt'
You can’t perform that action at this time.
0 commit comments