-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.h
165 lines (134 loc) · 4.75 KB
/
user.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef USER_H
#define USER_H
#include "collisionAttackTask_CPU.h"
/**
* @class user
* @brief Description of attack's target.
*/
class user : public QObject
{
Q_OBJECT
public:
user(const QString& username="", const QString& algid="", const QString& salt="", const QString& hashofpass="", QObject *parent=Q_NULLPTR);
/**
* @brief Constructs user object from JSON. Throws ParsingException if JSON object is incomplete w.r.t. user class.
*/
user(const QJsonObject& json, QObject *parent=Q_NULLPTR);
/**
* @brief Implemented for connection registeration.
*/
user(const user& other);
/**
* @brief Implemented for connection registeration.
*/
~user() {}
/**
* @brief Assignment.
*/
user operator=(const user& other);
/**
* @brief Setter of the user's data.
*/
void setUser(const QString& username, const QString& algid, const QString& salt, const QString& hashofpass);
/**
* @brief Getter of the user's name.
* @return User's name.
*/
QString getName() const {return m_username;}
/**
* @brief Gets user's hashing algorithm (scheme) ID.
* @return User's hashing algorithm (scheme) ID.
*/
QString getAlgid() const {return m_algid;}
/**
* @brief Getter of the user's salt.
* @return User's salt.
*/
QString getSalt() const {return m_salt;}
/**
* @brief Getter of the user's password hash.
* @return User's password hash.
*/
QString getHash() const {return m_hashofpass;}
/**
* @brief Get a hashing scheme's name by scheme's ID.
* @param algid - hashing algorithm (scheme) ID.
* @return Hashing scheme's name.
*/
static QString getAlgorithmName(const QString& algid);
/**
* @brief Export values from the User object to json.
* @param json - JSON object.
*/
void write_to_json(QJsonObject& json) const;
/**
* @brief Interrupts collisionAttackTask_CPU jobs, stops the attack's calculations.
* collision_attack()/resumed_collision_attack() completion command.
* @see collisionAttackTask_CPU, collisionAttackTask_CPU::stopAttack(), collision_attack(), attack_save()
*/
void attack_interrupt();
/**
* @brief Saves the user's attack's calculations, interrupts collisionAttackTask_CPU jobs,
* stops the attack's calculations.
* collision_attack()/resumed_collision_attack() completion command.
* @see collisionAttackTask_CPU::saveAttack(), collision_attack(), resumed_collision_attack(), attack_interrupt()
*/
void attack_save();
public slots:
/**
* @brief Performs the user's password's parallel finding.
* (each "password length"<->"heuristics mode" combo calculations performs in a separate thread).
* @see collisionAttackTask_CPU
*/
void collision_attack();
/**
* @brief Continues the user's password's parallel finding.
* (each "password length"<->"heuristics mode" combo calculations performs in a separate thread,
* starts from cached passwords as already reached milestone).
* @see collisionAttackTask_CPU
*/
void resumed_collision_attack();
signals:
/**
* @brief This signal is emitted when the calculations ending process has been activated and
* the attack has been successfully interrupted (after attack_interrupt() has been called).
* @see attack_interrupt()
*/
void signal_attackFinished();
private:
QString m_username;
/**
* @brief Hash scheme ID.
*/
QString m_algid;
/**
* @brief Hash function input modifier.
*/
QString m_salt;
/**
* @brief Password's hash.
*/
QString m_hashofpass;
/**
* @brief Supported hashing schemes.
* key - algorithm id, value - algorithm name.
*/
static std::map<QString, QString> m_halgorithm_types;
/**
* @brief Performs restricted brute-force attack with limited maximum password length and restricted alphabet.
* Runs (collisionAttackTask_CPU::m_optimal_max_pass_length - \a initial_password_length) separate attacks
* with different password's length.
* @param initial_password_length - minimum size (quantity of characters) of password for the attack's tasks.
* @see collisionAttackTask_CPU::Heuristic, unlimited_attack()
*/
void limited_attack(const uint& initial_password_length);
/**
* @brief Performs unrestricted brute-force attack without any Heuristics.
* Runs unlimited quantity of attacks until interruption.
* @param initial_password_length - minimum size (quantity of characters) of password for the attack's tasks.
* @see collisionAttackTask_CPU::Heuristic, limited_attack(), attack_interrupt(), attack_save()
*/
void unlimited_attack(const uint& initial_password_length);
};
Q_DECLARE_METATYPE(user)
#endif // USER_H