1
+ import { registerSchema } from "class-validator" ;
2
+ // import { UserValidationSchema } from "./schema.js";
3
+ // registerSchema(UserValidationSchema);
4
+ import { UserSchema } from "./schema"
5
+ import { validate } from "class-validator" ;
6
+ import { createConnection } from 'mysql2' ;
7
+ import { plainToClass , plainToInstance } from 'class-transformer'
8
+
9
+
10
+ let requirements = {
11
+ host : 'localhost' ,
12
+ user : 'root' ,
13
+ password : 'compsec2' ,
14
+ database : 'sqldatabase'
15
+ } ;
16
+
17
+ const connection = createConnection ( requirements ) ;
18
+ function bypassedValidation ( emailInput , passwordInput ) {
19
+ const sqlquery1 = `SELECT * FROM login WHERE email = ${ emailInput } AND password = ${ passwordInput } ` ;
20
+ connection . query ( sqlquery1 , function ( error , rows ) {
21
+ if ( error ) throw error ;
22
+ console . log ( rows ) ;
23
+ } ) ;
24
+ }
25
+
26
+ let schema = new UserSchema ( ) ;
27
+ schema . email = '' ;
28
+ schema . password = '' ;
29
+
30
+ let param = {
31
+ email : '" OR 1=1--' ,
32
+ password : '" OR 1=1--' ,
33
+ constructor : false
34
+ } ;
35
+
36
+ let test1Param = Object . assign ( schema , param ) ;
37
+ console . log ( test1Param ) ;
38
+
39
+ validate ( test1Param ) . then ( errors => {
40
+ if ( errors . length > 0 ) {
41
+ console . log ( 'email and or password of wrong form' , errors ) ;
42
+ } else { console . log ( 'email and password of correct form input' ) ;
43
+ bypassedValidation ( test1Param . email , test1Param . password ) ;
44
+ }
45
+ } ) ;
46
+
47
+
48
+ // let schema2 = new UserSchema();
49
+ // schema2.email = '';
50
+ // schema2.password = '';
51
+
52
+ // let ryn = {
53
+
54
+ // pssword: 'Paass2',
55
+ // incorrectField: 'I shouldnt be here',
56
+ // constructor: false
57
+ // };
58
+
59
+ // let rynParam = Object.assign(schema2, ryn);
60
+ // console.log(rynParam);
61
+
62
+
63
+ // validate(rynParam).then(errors => {
64
+ // if (errors.length > 0) {
65
+ // console.log('email and or password of wrong form', errors);
66
+ // } else {console.log('email and password of correct form input');
67
+ // bypassedValidation(rynParam.email, rynParam.password);
68
+ // }
69
+ // });
0 commit comments