feat: complete basic functions

Support http,dns and mysql connection. Support custom http, dns response. Support dns rebinding.
Support mysql load local files and jdbc deserialize exploit.
This commit is contained in:
Li4n0
2021-04-21 18:55:16 +08:00
parent e9db8ddb24
commit 3559894acc
114 changed files with 41617 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
package database
import "gorm.io/gorm"
var DB *gorm.DB
func InitDB(driver, dsn string) (err error) {
switch driver {
case "sqlite":
DB, err = NewSqlite3(dsn)
}
return
}
+27
View File
@@ -0,0 +1,27 @@
package database
import (
"database/sql/driver"
"encoding/json"
)
type MapField map[string]string
func (f MapField) Value() (driver.Value, error) {
return json.Marshal(f)
}
func (f *MapField) Scan(data interface{}) error {
return json.Unmarshal(data.([]byte), f)
}
type ListField []string
func (f ListField) Value() (driver.Value, error) {
return json.Marshal(f)
}
func (f *ListField) Scan(data interface{}) error {
return json.Unmarshal(data.([]byte), f)
}
+15
View File
@@ -0,0 +1,15 @@
package database
import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
func NewSqlite3(dsn string) (*gorm.DB, error) {
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{})
if err != nil {
return nil, err
}
db.Exec("PRAGMA foreign_keys=ON")
return db, nil
}