You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: a.i.-exploiting/bra.i.nsmasher-presentation/README.md
+8-4
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# BRA.I.NSMASHER Presentation
1
+
2
2
3
3
<details>
4
4
@@ -16,7 +16,8 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
16
16
17
17
</details>
18
18
19
-
## Presentation
19
+
20
+
# Presentation
20
21
21
22
**BrainSmasher** is a platform made with the purpose of aiding **pentesters, researcher, students, A.I. Cybersecurity engineers** to practice and learn all the techniques for **exploiting commercial A.I.** applications, by working on specifically crafted labs that reproduce several systems, like face recognition, speech recognition, ensemble image classification, autonomous drive, malware evasion, chatbot, data poisoning etc...
22
23
@@ -36,7 +37,7 @@ _A big thanks to Hacktricks and Carlos Polop for giving us this opportunity_
36
37
37
38
> _Walter Miele from BrA.I.nsmasher_
38
39
39
-
##Registry Challenge
40
+
# Registry Challenge
40
41
41
42
In order to register in [**BrA.I.Smasher**](https://beta.brainsmasher.eu)you need to solve an easy challenge ([**here**](https://beta.brainsmasher.eu/registrationChallenge)).\
42
43
Just think how you can confuse a neuronal network while not confusing the other one knowing that one detects better the panda while the other one is worse...
@@ -47,12 +48,13 @@ However, if at some point you **don't know how to solve** the challenge, or **ev
47
48
48
49
I have to tell you that there are **easier ways** to pass the challenge, but this **solution** is **awesome** as you will learn how to pass the challenge performing an **Adversarial Image performing a Fast Gradient Signed Method (FGSM) attack for images.**
Copy file name to clipboardexpand all lines: a.i.-exploiting/bra.i.nsmasher-presentation/basic-bruteforcer.md
+6-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Basic Bruteforcer
1
+
2
2
3
3
<details>
4
4
@@ -16,7 +16,8 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
16
16
17
17
</details>
18
18
19
-
## BRUTEFORCER IMAGE CORRUPTION SCRIPT
19
+
20
+
# BRUTEFORCER IMAGE CORRUPTION SCRIPT
20
21
21
22
The purpose here is to introduce the user to some basic concepts about **A.I. apps exploiting**, via some easy to follow scripts, which represents the core for writing useful tools.\<br>\
22
23
In this example (which can be used to solve the easy labs of BrainSmasher) by recalling also what is written in the solution for the introduction challenge, we will provide a simple yet useful way, in order to iteratively produce some corrupted images, to bruteforce the face recon easy labs (and thus also real applications that relies on the same principles)
@@ -29,6 +30,7 @@ Try it on our labs [**BrA.I.Smasher Website**](https://beta.brainsmasher.eu)
29
30
30
31
Enjoy and stay safe!
31
32
33
+
32
34
<details>
33
35
34
36
<summary><strong>Support HackTricks and get benefits!</strong></summary>
@@ -44,3 +46,5 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
44
46
**Share your hacking tricks submitting PRs to the**[**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
Copy file name to clipboardexpand all lines: a.i.-exploiting/bra.i.nsmasher-presentation/basic-captcha-breaker.md
+8-3
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Basic Captcha Breaker
1
+
2
2
3
3
<details>
4
4
@@ -16,10 +16,13 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
16
16
17
17
</details>
18
18
19
-
In this tutorial **a basic captcha is going to be broken**.\
19
+
20
+
In this tutorial **a basic captcha is going to be broken**.
20
21
A **NN is going to be trained** using several **images** that represents **letters** and then this NN is going to be used to **automatically identify the letters inside a captcha image**.
21
22
22
-
Check the awesome guided tutorial provided by [**BrA.In Smasher**](https://beta.brainsmasher.eu) in this [**google collab page**](https://colab.research.google.com/drive/1uiQJpqEj5V2\_ijoumSd2noaDJuniTlKq?usp=sharing).
23
+
Check the awesome guided tutorial provided by [**BrA.In Smasher**](https://beta.brainsmasher.eu/) in this [**google collab page**](https://colab.research.google.com/drive/1uiQJpqEj5V2_ijoumSd2noaDJuniTlKq?usp=sharing).
24
+
25
+
23
26
24
27
<details>
25
28
@@ -36,3 +39,5 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
36
39
**Share your hacking tricks submitting PRs to the**[**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
Copy file name to clipboardexpand all lines: a.i.-exploiting/bra.i.nsmasher-presentation/bim-bruteforcer.md
+8-3
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# BIM Bruteforcer
1
+
2
2
3
3
<details>
4
4
@@ -16,9 +16,10 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
16
16
17
17
</details>
18
18
19
-
## BRUTEFORCER CORE SCRIPT WITH BIM ATTACK
20
19
21
-
This time we introduce a new type of gradient based attack, in order to brute force an image classification app (can be shaped and used for any input of course), the BIM, or Basic Iteration Method.
20
+
# BRUTEFORCER CORE SCRIPT WITH BIM ATTACK
21
+
22
+
This time we introduce a new type of gradient based attack, in order to brute force an image classification app \(can be shaped and used for any input of course\), the BIM, or Basic Iteration Method.
22
23
23
24
It’s recommended to see at least the explanation in the [**introduction challenge colab Notebook**](https://colab.research.google.com/drive/1lDh0oZ3TR-z87WjogdegZCdtsUuDADcR)
24
25
@@ -30,6 +31,8 @@ As usual we will provide only the A.I. attack core part, it’s up to you to com
30
31
Remember, in those kind of scenarios, in order to mime real-based attack applications, we don’t have the exact model to fool or the image target in which we would like to transform our image. That’s why, in order to overcome this issue, we must blend our core script, with a bruteforcer logic, accordingly to the application responses we want to fool.
31
32
{% endhint %}
32
33
34
+
35
+
33
36
<details>
34
37
35
38
<summary><strong>Support HackTricks and get benefits!</strong></summary>
@@ -45,3 +48,5 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
45
48
**Share your hacking tricks submitting PRs to the**[**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
In this series of notebook we are going to build an **hybrid malware classifier.**
24
25
@@ -34,7 +35,9 @@ For the **Fourth Part** For the Fourth Part we will add some tactics to add robu
34
35
35
36
There are also many available datasets for Static and/ or Dynamic Malware analysis on several sites for this type of classification, like Ember, VirusShare, Sorel-20M, but i strongly encourage that you build one or your own.
36
37
37
-
Here’s the link to our [**colab notebook**](https://colab.research.google.com/drive/1nNZLMogXF-iq-\_78IvGTd-c89\_C82AB8#scrollTo=lUHLMl8Pusrn) enjoy and stay safe :)
38
+
Here’s the link to our [**colab notebook**](https://colab.research.google.com/drive/1nNZLMogXF-iq-_78IvGTd-c89_C82AB8#scrollTo=lUHLMl8Pusrn) enjoy and stay safe :\)
39
+
40
+
38
41
39
42
<details>
40
43
@@ -51,3 +54,5 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
51
54
**Share your hacking tricks submitting PRs to the**[**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
Copy file name to clipboardexpand all lines: a.i.-exploiting/bra.i.nsmasher-presentation/ml-basics/feature-engineering.md
+21-17
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Feature Engineering
1
+
2
2
3
3
<details>
4
4
@@ -16,21 +16,22 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
16
16
17
17
</details>
18
18
19
-
## Basic types of possible data
19
+
20
+
# Basic types of possible data
20
21
21
22
Data can be **continuous** (**infinity** values) or **categorical** (nominal) where the amount of possible values are **limited**.
22
23
23
-
###Categorical types
24
+
## Categorical types
24
25
25
-
####Binary
26
+
### Binary
26
27
27
28
Just **2 possible values**: 1 or 0. In case in a dataset the values are in string format (e.g. "True" and "False") you assign numbers to those values with:
The **values follows an order**, like in: 1st place, 2nd place... If the categories are strings (like: "starter", "amateur", "professional", "expert") you can map them to numbers as we saw in the binary case.
36
37
@@ -49,7 +50,7 @@ possible_values_mapping = {value:idx for idx,value in enumerate(possible_values_
Looks **like ordinal value** because there is an order, but it doesn't mean one is bigger than the other. Also the **distance between them depends on the direction** you are counting. Example: The days of the week, Sunday isn't "bigger" than Monday.
Date are **continuous****variables**. Can be seen as **cyclical** (because they repeat) **or** as **ordinal** variables (because a time is bigger than a previous one).
**More than 2 categories** with no related order. Use `dataset.describe(include='all')` to get information about the categories of each feature.
100
101
@@ -107,7 +108,7 @@ You can get a **multi-category column one-hot encoded** with `pd.get_dummies(dat
107
108
108
109
You can get a **multi-category column dummie encoded** with `pd.get_dummies(dataset.column1, drop_first=True)`. This will transform all the classes in binary features, so this will create **one new column per possible class minus one** as the **last 2 columns will be reflect as "1" or "0" in the last binary column created**. This will avoid perfect multicollinearity, reducing the relations between columns.
109
110
110
-
##Collinear/Multicollinearity
111
+
# Collinear/Multicollinearity
111
112
112
113
Collinear appears when **2 features are related to each other**. Multicollineratity appears when those are more than 2.
113
114
@@ -125,7 +126,7 @@ X = add_constant(onehot_encoded) # Add previously one-hot encoded data
125
126
print(pd.Series([variance_inflation_factor(X.values,i) for i inrange(X.shape[1])], index=X.columns))
126
127
```
127
128
128
-
##Categorical Imbalance
129
+
# Categorical Imbalance
129
130
130
131
This occurs when there is **not the same amount of each category** in the training data.
131
132
@@ -174,7 +175,7 @@ You can use the argument **`sampling_strategy`** to indicate the **percentage**
174
175
Undersamplig or Oversampling aren't perfect if you get statistics (with `.describe()`) of the over/under-sampled data and compare them to the original you will see **that they changed.** Therefore oversampling and undersampling are modifying the training data.
175
176
{% endhint %}
176
177
177
-
###SMOTE oversampling
178
+
## SMOTE oversampling
178
179
179
180
**SMOTE** is usually a **more trustable way to oversample the data**.
print(y_smote.value_counts()) #Confirm data isn't imbalanced anymore
190
191
```
191
192
192
-
##Rarely Occurring Categories
193
+
# Rarely Occurring Categories
193
194
194
195
Imagine a dataset where one of the target classes **occur very little times**.
195
196
196
197
This is like the category imbalance from the previous section, but the rarely occurring category is occurring even less than "minority class" in that case. The **raw****oversampling** and **undersampling** methods could be also used here, but generally those techniques **won't give really good results**.
197
198
198
-
###Weights
199
+
## Weights
199
200
200
201
In some algorithms it's possible to **modify the weights of the targeted data** so some of them get by default more importance when generating the model.
201
202
@@ -206,13 +207,13 @@ model = LogisticRegression(class_weight=weights)
206
207
207
208
You can **mix the weights with over/under-sampling techniques** to try to improve the results.
208
209
209
-
###PCA - Principal Component Analysis
210
+
## PCA - Principal Component Analysis
210
211
211
212
Is a method that helps to reduce the dimensionality of the data. It's going to **combine different features** to **reduce the amount** of them generating **more useful features** (_less computation is needed_).
212
213
213
214
The resulting features aren't understandable by humans, so it also **anonymize the data**.
214
215
215
-
##Incongruent Label Categories
216
+
# Incongruent Label Categories
216
217
217
218
Data might have mistakes for unsuccessful transformations or just because human error when writing the data.
218
219
@@ -222,7 +223,7 @@ You can clean this issues by lowercasing everything and mapping misspelled label
222
223
223
224
It's very important to check that **all the data that you have contains is correctly labeled**, because for example, one misspelling error in the data, when dummie encoding the classes, will generate a new column in the final features with **bad consequences for the final model**. This example can be detected very easily by one-hot encoding a column and checking the names of the columns created.
224
225
225
-
##Missing Data
226
+
# Missing Data
226
227
227
228
Some data of the study may be missing.
228
229
@@ -290,7 +291,7 @@ dataset.iloc[10:20] # Get some indexes that contained empty data before
290
291
291
292
To fill categorical data first of all you need to think if there is any reason why the values are missing. If it's by **choice of the users** (they didn't want to give the data) maybe yo can **create a new category** indicating that. If it's because of human error you can **remove the rows** or the **feature** (check the steps mentioned before) or **fill it with the mode, the most used category** (not recommended).
292
293
293
-
##Combining Features
294
+
# Combining Features
294
295
295
296
If you find **two features** that are **correlated** between them, usually you should **drop** one of them (the one that is less correlated with the target), but you could also try to **combine them and create a new feature**.
296
297
@@ -307,6 +308,7 @@ X = add_constant(dataset[['column1', 'column2', 'target']])
307
308
pd.Series([variance_inflation_factor(X.values, i) for i inrange(X.shape[1])], index=X.columns)
308
309
```
309
310
311
+
310
312
<details>
311
313
312
314
<summary><strong>Support HackTricks and get benefits!</strong></summary>
@@ -322,3 +324,5 @@ Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
322
324
**Share your hacking tricks submitting PRs to the**[**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
0 commit comments