Kaynağa Gözat

Check a given hash against the tripwire database

Bob Mottram 7 yıl önce
ebeveyn
işleme
659e49c477
1 değiştirilmiş dosya ile 38 ekleme ve 3 silme
  1. 38
    3
      src/freedombone-controlpanel

+ 38
- 3
src/freedombone-controlpanel Dosyayı Görüntüle

129
 fi
129
 fi
130
 
130
 
131
 function any_key {
131
 function any_key {
132
-    echo ' '
133
-    read -n1 -r -p $"Press any key to continue..." key
132
+    echo ''
133
+    read -n1 -rsp $"Press any key to continue..." key
134
+}
135
+
136
+function any_key_verify {
137
+    echo ''
138
+    read -n1 -rsp $"Press any key to continue or C to check a hash..." key
139
+    if [[ "$key" != 'c' && "$key" != 'C' ]]; then
140
+        return
141
+    fi
142
+
143
+    data=$(tempfile 2>/dev/null)
144
+    trap "rm -f $data" 0 1 2 5 15
145
+    dialog --title $"Check tripwire hash" \
146
+           --backtitle $"Freedombone Control Panel" \
147
+           --inputbox $"Paste your tripwire hash below and it will be checked against the current database" 12 60 2>$data
148
+    sel=$?
149
+    case $sel in
150
+        0)
151
+            GIVEN_HASH=$(<$data)
152
+            if [ ${#GIVEN_HASH} -gt 8 ]; then
153
+                if [[ "$GIVEN_HASH" == *' '* ]]; then
154
+                    dialog --title $"Check tripwire" \
155
+                           --msgbox $"\nThe hash should not contain any spaces" 10 40
156
+                else
157
+                    DBHASH=$(sha512sum  /var/lib/tripwire/${HOSTNAME}.twd | awk -F ' ' '{print $1}')
158
+                    if [[ "$DBHASH" == "$GIVEN_HASH" ]]; then
159
+                        dialog --title $"Check tripwire" \
160
+                               --msgbox $"\nSuccess\n\nThe hash you gave matches the current tripwire database" 10 40
161
+                    else
162
+                        dialog --title $"Check tripwire" \
163
+                               --msgbox $"\nFailed\n\nThe hash you gave does not match the current tripwire database. This might be because you reset the tripwire, or there could have been an unauthorised modification of the system" 12 50
164
+                    fi
165
+                fi
166
+            fi
167
+            ;;
168
+    esac
134
 }
169
 }
135
 
170
 
136
 function get_app_icann_address {
171
 function get_app_icann_address {
1325
     else
1360
     else
1326
         echo $'ERROR: tripwire database was not created'
1361
         echo $'ERROR: tripwire database was not created'
1327
     fi
1362
     fi
1328
-    any_key
1363
+    any_key_verify
1329
 }
1364
 }
1330
 
1365
 
1331
 function format_drive {
1366
 function format_drive {