Skip to content

Commit a5fb0d0

Browse files
author
root
committed
modified: bin/install.sh
- fixed missing ${TMPDIR} - adapted to work with newest cowrie - adapted to work in openSUSE with selinux modified: bin/makecert.sh - fixed issue with location of dshield.sslca modified: bin/status.sh - fixed egrep to grep -E modified: bin/update.sh - fixed egrep to grep -E modified: bin/updatehoneypotip.sh - fixed egrep to grep -E - fixed location of dshield.ini modified: docs/install-instructions/openSUSE.md - updated documentation for openSUSE modified: srv/dshield/DShield.patch - extra character, C, used in line in dshield.log new files needed for selinux in openSUSE and new version of cowrie - etc/cowrie.pp - etc/cowrie1.pp - srv/cowrie/bin/
1 parent cec8e49 commit a5fb0d0

File tree

7 files changed

+165
-83
lines changed

7 files changed

+165
-83
lines changed

bin/install.sh

Lines changed: 99 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ readonly myversion=98
2020

2121
# Major Changes (for details, see Github):
2222
#
23+
# - V99 (Freek)
24+
# - fixed some missing sudos
25+
# - adapted to support newest openSUSE
26+
# - added the https port 8443
27+
#
2328
# - V98 (Johannes)
2429
# - new web hpot (Mark Baggett)
2530
# - installer no longer requires root / better priv separation
@@ -293,10 +298,11 @@ LOGFILE="${LOGDIR}/install_${INSTDATE}.log"
293298
SSHHONEYPORT=2222
294299
TELNETHONEYPORT=2223
295300
WEBHONEYPORT=8000
301+
HTTPSHONEYPORT=8443
296302
SSHREDIRECT="22"
297303
TELNETREDIRECT="23 2323"
298304
WEBREDIRECT="80 8080 7547 5555 9000"
299-
HONEYPORTS="${SSHHONEYPORT} ${TELNETHONEYPORT} ${WEBHONEYPORT}"
305+
HONEYPORTS="${SSHHONEYPORT} ${TELNETHONEYPORT} ${WEBHONEYPORT} ${HTTPSHONYPORT}"
300306

301307
# create and setup log directory
302308
if [ ! -d ${LOGDIR} ]; then
@@ -771,10 +777,10 @@ if [ "$FAST" == "0" ]; then
771777
outlog "Updating your openSUSE Operating System will now be done."
772778
sudorun 'zypper --non-interactive dup --no-recommends'
773779
outlog "Installing additional packages"
774-
sudorun 'zypper --non-interactive install --no-recommends cron gcc libffi-devel python311-devel libopenssl-devel rsyslog dialog'
780+
sudorun 'zypper --non-interactive install --no-recommends cron gcc libffi-devel python3-devel libopenssl-devel rsyslog dialog'
775781
sudorun 'zypper --non-interactive install --no-recommends perl-libwww-perl perl-Switch perl-LWP-Protocol-https python3-requests'
776-
sudorun 'zypper --non-interactive install --no-recommends python3-pycryptodome python3-virtualenv'
777-
sudorun 'zypper --non-interactive install --no-recommends python311-pip rng-tools curl openssh unzip'
782+
sudorun 'zypper --non-interactive install --no-recommends python3-pycryptodome python3-virtualenv python3-dateutils'
783+
sudorun 'zypper --non-interactive install --no-recommends python3-pip rng-tools curl openssh unzip'
778784
sudorun 'zypper --non-interactive install --no-recommends net-tools-deprecated patch logrotate'
779785
sudorun 'zypper --non-interactive install --no-recommends system-user-mail mariadb libmariadb-devel python3-PyMySQL jq'
780786
sudorun 'zypper --non-interactive install --no-recommends python3-python-snappy snappy-devel gcc-c++'
@@ -886,7 +892,7 @@ if [ -x /etc/init.d/cowrie ]; then
886892
fi
887893
# in case systemd is used
888894
outlog "Stopping cowrie via systemd"
889-
sudo systemctl stop cowrie
895+
[ "$(sudo systemcl is-active cowrie.service)" = "active" ] && sudo systemctl stop cowrie
890896

891897
if [ "$FAST" == "0" ]; then
892898

@@ -980,16 +986,8 @@ EOF
980986
drun "cat /etc/modprobe.d/ipv6.conf.bak"
981987
drun "cat /etc/modprobe.d/ipv6.conf"
982988
else # in openSUSE
983-
run "grep -q 'ipv6.conf' /etc/sysctl.d/70-yast.conf"
984-
# shellcheck disable=SC2181
985-
if [ ${?} -ne 0 ]; then
986-
dlog "Disabling IPv6 in /etc/sysctl.d/70-yast.conf"
987-
dsudorun 'echo "net.ipv4.ip_forward = 0" >> /etc/sysctl.d/70-yast.conf'
988-
dsudorun 'echo "net.ipv6.conf.all.forwarding = 0" >> /etc/sysctl.d/70-yast.conf'
989-
dsudorun 'echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/70-yast.conf'
990-
else
991-
dlog "IPv6 already disabled in /etc/sysctl.d/70-yast.conf"
992-
fi
989+
iface=$(ip -4 route show | grep '^default ' | head -1 | cut -f5 -d' ')
990+
dsudorun "nmcli device modify $iface ipv6.method 'disabled'"
993991
fi
994992

995993
###########################################################
@@ -1001,7 +999,8 @@ if ! grep -qE '^webhpot' /etc/passwd; then
1001999
if [ "$ID" != "opensuse" ]; then
10021000
sudorun 'adduser --gecos "Honeypot,A113,555-1212,555-1212" --disabled-password --quiet --home /srv/web --no-create-home webhpot'
10031001
else
1004-
sudorun 'useradd -c "Honeypot,A113,555-1212,555-1212" -M -U -d /srv/web webhpot'
1002+
sudorun 'useradd -c "Honeypot,A113,555-1212,555-1212" -M -U -d /srv/web webhpot'
1003+
sudorun 'passwd -d webhpot' #disable password
10051004
fi
10061005
outlog "Added user 'webhpot'"
10071006
else
@@ -1778,7 +1777,7 @@ EOF
17781777

17791778
else # use_iptables = False -> use nftables
17801779
dlog "using nftables, not iptables"
1781-
cat > /etc/network/ruleset.nft <<EOF
1780+
cat > ${TMPDIR}/ruleset.nft <<EOF
17821781
# NFT ruleset generated on $(date)
17831782
add table ip filter
17841783
add chain ip filter INPUT { type filter hook input priority 0; policy drop; }
@@ -1789,7 +1788,7 @@ add rule ip filter INPUT iifname "${interface}" ct state related,established co
17891788
EOF
17901789

17911790
# allow pings from localnet
1792-
echo "# allow ping from local network" >>/etc/network/ruleset.nft
1791+
echo "# allow ping from local network" >>${TMPDIR}/ruleset.nft
17931792
echo "add rule ip filter INPUT iifname \"$interface\" ip saddr ${localnet} icmp type echo-request counter accept" >>"${TMPDIR}"/ruleset.nft
17941793

17951794
# insert IPs and ports for which honeypot has to be disabled
@@ -1928,24 +1927,53 @@ fi
19281927
if [ "$INTERACTIVE" == 1 ]; then
19291928
dlog "changing port for sshd"
19301929

1931-
run "sed \"s/^[#\s]*Port 22\s*$/Port ${SSHDPORT}/\" < /etc/ssh/sshd_config > ${TMPDIR}/sshd_config"
1932-
sudorun "mv ${TMPDIR}/sshd_config /etc/ssh/sshd_config"
1933-
1934-
dlog "checking if modification was successful"
1935-
if [ "$(grep -c "^Port ${SSHDPORT}$" /etc/ssh/sshd_config)" -ne 1 ]; then
1936-
dialog --title 'sshd port' --ok-label 'Understood.' --cr-wrap --msgbox "Congrats, you had already changed your sshd port to something other than 22.
1937-
1930+
if [ -f /etc/ssh/sshd_config ] ; then
1931+
run "sed \"s/^[#\s]*Port 22\s*$/Port ${SSHDPORT}/\" < /etc/ssh/sshd_config > ${TMPDIR}/sshd_config"
1932+
sudorun "mv ${TMPDIR}/sshd_config /etc/ssh/sshd_config"
1933+
dlog "checking if modification was successful"
1934+
if [ "$(grep -c "^Port ${SSHDPORT}$" /etc/ssh/sshd_config)" -ne 1 ]; then
1935+
dialog --title 'sshd port' --ok-label 'Understood.' --cr-wrap --msgbox "Congrats, you had already changed your sshd port to something other than 22.
19381936
Please clean up and either
19391937
- change the port manually to ${SSHDPORT}
19401938
in /etc/ssh/sshd_config OR
19411939
- clean up the firewall rules and
19421940
other stuff reflecting YOUR PORT" 13 50
1943-
clear
1941+
clear
19441942

1945-
dlog "check unsuccessful, port ${SSHDPORT} not found in sshd_config"
1946-
drun 'cat /etc/ssh/sshd_config | grep -v "^\$" | grep -v "^#"'
1947-
else
1948-
dlog "check successful, port change to ${SSHDPORT} in sshd_config"
1943+
dlog "check unsuccessful, port ${SSHDPORT} not found in sshd_config"
1944+
drun 'cat /etc/ssh/sshd_config | grep -v "^\$" | grep -v "^#"'
1945+
else
1946+
dlog "check successful, port change to ${SSHDPORT} in sshd_config"
1947+
fi
1948+
else # when /etc/ssh/sshd_config does not exist
1949+
if [ "$(cat /etc/ssh/sshd_config.d/*.conf | grep -c "^Port ${SSHDPORT}\$")" -ne 0 ] ; then
1950+
dlog "check succesfull, port changed to ${SSHDPORT} in a file in /etc/ssh/sshd.config.d/"
1951+
else
1952+
if [ -n "$(cat /etc/ssh/sshd_config.d/*.conf)" ] && [ "$(cat /etc/ssh/sshd_config.d/*.conf | grep -c "^Port ")" -ge 1 ] ; then
1953+
dialog --title 'sshd port' --ok-label 'Understood.' --cr-wrap --msgbox "Congrats, you had already changed your sshd port to something other than 22.
1954+
Please clean up and either
1955+
- change the port manually to ${SSHDPORT}
1956+
in a file in /etc/ssh/sshd_config.d/*.conf OR
1957+
- clean up the firewall rules and
1958+
other stuff reflecting YOUR PORT" 13 50
1959+
clear
1960+
else # a file Port*.conf does not exist
1961+
echo "Port ${SSHDPORT}" > "${TMPDIR}"/Port_${SSHDPORT}.conf
1962+
sudorun "mv ${TMPDIR}/Port_${SSHDPORT}.conf /etc/ssh/sshd_config.d/"
1963+
sudorun "chown root:root /etc/ssh/sshd_config.d/Port_${SSHDPORT}.conf"
1964+
if [ -x /usr/sbin/getenforce ] ; then
1965+
if [ "$(sudo /usr/sbin/getenforce)" = "Enforcing" ] ; then
1966+
if [ ! -x /usr/sbin/semanage ] ; then
1967+
sudorun "zypper --non-interactive in --no-recommends policycoreutils-python-utils"
1968+
else
1969+
echo "ERROR utility semanage needs to be installed, exiting!!"
1970+
exit 9
1971+
fi
1972+
fi
1973+
sudorun "semanage port -a -t ssh_port_t -p tcp ${SSHDPORT}"
1974+
fi
1975+
fi
1976+
fi
19491977
fi
19501978
fi # interactive
19511979
###########################################################
@@ -1964,7 +1992,7 @@ fi
19641992

19651993

19661994

1967-
dsudorun 'cat /etc/rsyslog.d/dshield.conf'
1995+
dsudorun 'cat /etc/rsyslog.d/10-dshield.conf'
19681996

19691997
###########################################################
19701998
## Further copying / configuration
@@ -1987,7 +2015,8 @@ if ! grep -qE '^webhpot' /etc/passwd; then
19872015
if [ "$ID" != "opensuse" ]; then
19882016
sudorun 'adduser --gecos "Honeypot,A113,555-1212,555-1212" --disabled-password --quiet --home /srv/web --no-create-home webhpot'
19892017
else
1990-
sudorun 'useradd -c "Honeypot,A113,555-1212,555-1212" -M -U -d /srv/web webhpot'
2018+
sudorun 'useradd -c "Honeypot,A113,555-1212,555-1212" -M -U -d /srv/web webhpot'
2019+
sudorun 'passwd -d webhpot' # disable password
19912020
fi
19922021
outlog "Added user 'webhpot'"
19932022
else
@@ -2022,8 +2051,9 @@ if [ -f ${DSHIELDDIR}/updatehoneypotip.sh ]; then
20222051
run "rm ${DSHIELDDIR}/updatehoneypotip.sh"
20232052
fi
20242053
do_copy "$progdir"/updatehoneypotip.sh ${DSHIELDDIR} 700
2025-
[ "$ID" = "opensuse" ] &&
2054+
if [ "$ID" = "opensuse" ]; then
20262055
run "patch ${DSHIELDDIR}/DShield.py $progdir/../srv/dshield/DShield.patch"
2056+
fi
20272057

20282058
# check: automatic updates allowed?
20292059

@@ -2164,6 +2194,7 @@ if ! grep '^cowrie:' -q /etc/passwd; then
21642194
sudorun 'adduser --gecos "Honeypot,A113,555-1212,555-1212" --disabled-password --quiet --home /srv/cowrie --no-create-home cowrie'
21652195
else
21662196
sudorun 'useradd -c "Honeypot,A113,555-1212,555-1212" -M -U -d /srv/cowrie cowrie'
2197+
sudorun 'passwd -d cowrie' # disable password
21672198
fi
21682199
outlog "Added user 'cowrie'"
21692200
else
@@ -2254,6 +2285,8 @@ if [ "$FAST" == "0" ]; then
22542285
run 'sg cowrie -c "pip3 install --require-virtualenv --upgrade bcrypt"'
22552286
run 'sg cowrie -c "pip3 install --require-virtualenv --upgrade requests"'
22562287
run 'sg cowrie -c "pip3 install --require-virtualenv -r requirements.txt"'
2288+
run 'sg cowrie -c "pip3 install --require-virtualenv dateutils"'
2289+
run 'sg cowrie -c "pip3 install --require-virtualenv -e ."'
22572290
# shellcheck disable=SC2181
22582291
if [ ${?} -ne 0 ]; then
22592292
outlog "Error installing dependencies from requirements.txt. See ${LOGFILE} for details."
@@ -2282,7 +2315,8 @@ outlog "Doing further cowrie configuration."
22822315

22832316
# step 6 (Generate a DSA key)
22842317
dlog "generating cowrie SSH host key"
2285-
sudorun "ssh-keygen -t dsa -b 1024 -N '' -f ${COWRIEDIR}/var/lib/cowrie/ssh_host_dsa_key "
2318+
# dsa is too insecure and possibly not supported anymore in ssh-keygen; so use rsa
2319+
sudorun "ssh-keygen -t rsa -b 1024 -N '' -f ${COWRIEDIR}/var/lib/cowrie/ssh_host_rsa_key "
22862320

22872321
# step 5 (Install configuration file)
22882322
dlog "copying cowrie.cfg and adding entries"
@@ -2315,13 +2349,20 @@ dlog "creating output for text commands"
23152349

23162350
sudorun "mkdir -p ${TXTCMDS}/bin"
23172351
sudorun "mkdir -p ${TXTCMDS}/usr/bin"
2318-
sudorun "df > ${TXTCMDS}/bin/df"
2319-
sudorun "dmesg > ${TXTCMDS}/bin/dmesg"
2320-
sudorun "mount > ${TXTCMDS}/bin/mount"
2321-
sudorun "ulimit > ${TXTCMDS}/bin/ulimit"
2322-
sudorun "lscpu > ${TXTCMDS}/usr/bin/lscpu"
2323-
sudorun "echo '-bash: emacs: command not found' > ${TXTCMDS}/usr/bin/emacs"
2324-
sudorun "echo '-bash: locate: command not found' > ${TXTCMDS}/usr/bin/locate"
2352+
sudorun "df > ${TMPDIR}/df"
2353+
sudorun "mv ${TMPDIR}/df ${TXTCMDS}/bin/df"
2354+
sudorun "dmesg > ${TMPDIR}/dmesg"
2355+
sudorun "mv ${TMPDIR}/dmesg ${TXTCMDS}/bin/dmesg"
2356+
sudorun "mount > ${TMPDIR}/mount"
2357+
sudorun "mv ${TMPDIR}/mount ${TXTCMDS}/bin/mount"
2358+
run "ulimit > ${TMPDIR}/ulimit"
2359+
sudorun "mv ${TMPDIR}/ulimit ${TXTCMDS}/bin/ulimit"
2360+
sudorun "lscpu > ${TMPDIR}/lscpu"
2361+
sudorun "mv ${TMPDIR}/lscpu ${TXTCMDS}/usr/bin/lscpu"
2362+
sudorun "echo '-bash: emacs: command not found' > ${TMPDIR}/emacs"
2363+
sudorun "mv ${TMPDIR}/emacs ${TXTCMDS}/usr/bin/emacs"
2364+
sudorun "echo '-bash: locate: command not found' > ${TMPDIR}/locate"
2365+
sudorun "mv ${TMPDIR}/locate ${TXTCMDS}/usr/bin/locate"
23252366

23262367
sudorun "chown -R cowrie:cowrie ${COWRIEDIR}"
23272368

@@ -2330,7 +2371,17 @@ sudorun "chown -R cowrie:cowrie ${COWRIEDIR}"
23302371
dlog "copying cowrie system files"
23312372

23322373
sudo_copy "$progdir"/../lib/systemd/system/cowrie.service /lib/systemd/system/cowrie.service 644
2374+
# file copied/added from previous version of cowrie
2375+
sudo_copy "$progdir"/../srv/cowrie/bin/cowrie /srv/cowrie/bin/cowrie
2376+
sudorun chmod cowrie:cowrie /srv/cowrie/bin/cowrie
23332377
sudo_copy "$progdir"/../etc/cron.hourly/cowrie /etc/cron.hourly 755
2378+
if [ "$ID" = opensuse ] ; then
2379+
# add some selinux policy rules to let cowrie.service succeed
2380+
sudo_copy "$progdir"/../etc/cowrie.pp /etc/ 644
2381+
sudo_copy "$progdir"/../etc/cowrie1.pp /etc/ 644
2382+
sudorun semodule -i /etc/cowrie.pp
2383+
sudorun semodule -i /etc/cowrie1.pp
2384+
fi
23342385

23352386
# make sure to remove old cowrie start if they exist
23362387
if [ -f /etc/init.d/cowrie ]; then
@@ -2347,7 +2398,8 @@ sudorun 'systemctl daemon-reload'
23472398
sudorun 'systemctl enable cowrie.service'
23482399

23492400
dlog 'deactivate cowrie venv'
2350-
sudorun 'deactivate'
2401+
#sudorun 'deactivate'
2402+
run deactivate
23512403

23522404

23532405
###########################################################
@@ -2372,7 +2424,9 @@ sudo -u webhpot find ./isc_agent -mindepth 1 -type d -exec rm -rf {} +
23722424
sudo_copy "${progdir}"/../srv/web/web-honeypot.service /etc/systemd/system/web-honeypot.service 644
23732425
cd "${WEBHPOTDIR}" || exit
23742426
# disable old service in case it is still enabled
2375-
sudorun "systemctl disable isc-agent.service"
2427+
if [ "$(sudo systemctl is-enabled isc-agent.service)" = "enabled" ] ; then
2428+
sudorun "systemctl disable isc-agent.service"
2429+
fi
23762430
# enable new service
23772431
sudorun "systemctl daemon-reload"
23782432
sudorun "systemctl enable web-honeypot.service"
@@ -2542,7 +2596,7 @@ run 'mkdir -p /var/tmp/dshield'
25422596

25432597
# rotate dshield firewall logs
25442598
sudo_copy "$progdir"/../etc/logrotate.d/dshield /etc/logrotate.d 644
2545-
[ "$ID" = "opensuse" ] && sed -e 's/\/usr\/lib.*$/systemctl reload rsyslog/' -i /etc/logrotate.d/dshield
2599+
[ "$ID" = "opensuse" ] && sudo sed -e 's/\/usr\/lib.*$/systemctl reload rsyslog/' -i /etc/logrotate.d/dshield
25462600
if [ -f "/etc/cron.daily/logrotate" ]; then
25472601
sudorun "mv /etc/cron.daily/logrotate /etc/cron.hourly"
25482602
fi
@@ -2568,7 +2622,7 @@ fi
25682622
###########################################################
25692623

25702624
if [ -f /root/bin/postinstall.sh ]; then
2571-
run "/root/bin/postinstall.sh"
2625+
sudorun "/root/bin/postinstall.sh"
25722626
else
25732627
outlog
25742628
outlog

bin/makecert.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ if [ ! -f ${d}/../etc/CA/ca.serial ]; then
1414
echo -n $serial > "${d}/../etc/CA/ca.serial"
1515
fi
1616

17-
if [ -f $d/../etc/dshield.sslca ] ; then
18-
. $d/../etc/dshield.sslca
19-
else
20-
country="US"
21-
state="Florida"
22-
city="Jacksonville"
23-
company="DShield"
24-
depart="Decoy"
17+
dshieldsslca="/etc/dshield.sslca"
18+
if [ ! -f $dshieldsslca ] ; then
19+
dshieldsslca="$d/../etc/dshield.sslca"
2520
fi
26-
hostname=$(hostname);
21+
if [ -f $dshieldsslca ] ; then
22+
. $dshieldsslca
23+
fi
24+
if [ -z "$country" ] ; then
25+
country="US"
26+
state="Florida"
27+
city="Jacksonville"
28+
company="DShield"
29+
depart="Decoy"
30+
fi
31+
hostname=$(hostname)
2732
if [ "$interactive" -eq "1" ]; then
2833
exec 3>&1
2934
dialog --title 'Creating SSL Certificate' --separate-widget $'\n' --form\
@@ -47,6 +52,7 @@ if [ "$interactive" -eq "1" ]; then
4752
echo "city=\"$city\"" >> $d/../etc/dshield.sslca
4853
echo "company=\"$company\"" >> $d/../etc/dshield.sslca
4954
echo "depart=\"$department\"" >> $d/../etc/dshield.sslca
55+
sudo cp $d/../etc/dshield.sslca /etc/dshield.sslca
5056
}
5157
fi
5258
if [ ! -d $d/../etc/CA/keys ]; then

bin/status.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fi
128128
if echo $status | grep -q '<result>ok</result>'; then
129129
echo "${GREEN}API Key configuration ok${NC}"
130130
if [ "$version" != "" ]; then
131-
currentversion=$(echo $status | egrep -o '<version>([0-9\.]+)</version>' | egrep -o '[0-9\.]+')
131+
currentversion=$(echo $status | grep -E -o '<version>([0-9\.]+)</version>' | grep -E -o '[0-9\.]+')
132132
if [ "$currentversion" != "$version" ]; then
133133
echo "
134134
${RED}Software Version Mismatch

bin/update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ hash=`echo -n $email:$apikey | openssl dgst -hmac $nonce -sha512 -hex | cut -f2
4949
checkapikey=$(curl -s https://isc.sans.edu/api/checkapikey/$user/$nonce/$hash/$version/$piid)
5050
if echo $checkapikey | grep -q '<result>ok</result>'; then
5151
echo "API Key OK"
52-
newversion=$(echo $checkapikey | egrep -o '<version>[^<]+</version>'|egrep -o '[0-9]+')
52+
newversion=$(echo $checkapikey | grep -E -o '<version>[^<]+</version>'|grep -E -o '[0-9]+')
5353
else
5454
echo "Bad API Key. check API key in /etc/dshield.ini"
5555
exit

bin/updatehoneypotip.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@ if [ ! "$userid" = "0" ]; then
88
exit 9
99
fi
1010

11-
if [ ! -f /srv/dshield/etc/dshield.ini ]; then
12-
echo "missing /srv/dshield/etc/dshield.ini file"
11+
if [ ! -f /etc/dshield.ini ]; then
12+
echo "missing /etc/dshield.ini file"
1313
exit 9
1414
fi
1515
honeypotip=$(curl -s https://www4.dshield.org/api/myip?json | jq .ip | tr -d '"')
16-
if echo -n $honeypotip | egrep -q '^[0-9\.]+$'; then
17-
sed -i "s/^honeypotip=.*/honeypotip=$honeypotip/" /srv/dshield/etc/dshield.ini
18-
if ! grep -q '^piid=' dshield.ini; then
19-
piid=$(openssl rand -hex 10)
20-
sed -i "^apikey/a piid=$piid" /srv/dshield/etc/dshield.ini
21-
fi
16+
if echo -n $honeypotip | grep -E -q '^[0-9\.]+$'; then
17+
sed -i "s/^honeypotip=.*/honeypotip=$honeypotip/" /etc/dshield.ini
2218
else
2319
echo "Bad IP address"
2420
exit 9

0 commit comments

Comments
 (0)