mongo客户端

mgo手册 https://my.oschina.net/ffs/blog/300148

  1. package main
  2. import (
  3. "fmt"
  4. "gopkg.in/mgo.v2"
  5. "gopkg.in/mgo.v2/bson"
  6. )
  7. type admin struct {
  8. Id bson.ObjectId `bson:"_id"`
  9. Username string `bson:"username"`
  10. Password string `bson:password`
  11. }
  12. func main() {
  13. session,err := mgo.Dial("192.168.0.174") // server地址
  14. if err != nil{panic(err)}
  15. db := session.DB("admin") // 切换数据库
  16. c := db.C("admin") // 切换collection
  17. results := make([]admin,0)
  18. if err := c.Find(nil).All(&results);err!=nil{
  19. panic(err)
  20. }
  21. for _,res := range results{
  22. fmt.Println(res.Username,res.Password)
  23. }
  24. }

image.png

mysql客户端

  1. package main
  2. import (
  3. "database/sql"
  4. "fmt"
  5. _ "github.com/go-sql-driver/mysql" // 仅执行init函数,不导入整个包
  6. )
  7. var user string
  8. func main() {
  9. db,err := sql.Open("mysql", "root:root@tcp(192.168.0.174:3306)/mysql")
  10. if err !=nil{panic(err)}
  11. rows,err := db.Query("select user()")
  12. defer rows.Close()
  13. if err != nil{panic(err)}
  14. for rows.Next(){
  15. err := rows.Scan(&user)
  16. if err != nil{panic(err)}
  17. fmt.Println(user)
  18. }
  19. }

image.png

特殊文件搜集

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "path/filepath"
  6. "regexp"
  7. )
  8. var regexps = [] *regexp.Regexp{
  9. regexp.MustCompile(`(?i)user`),
  10. regexp.MustCompile(`(?i)conf`),
  11. regexp.MustCompile(`(?i)key`),
  12. regexp.MustCompile(`(?i)pass(?i)`),
  13. }
  14. func main() {
  15. root := os.Args[1]
  16. if err:=filepath.Walk(root,walkFn);err!=nil{
  17. panic(err)
  18. }
  19. }
  20. func walkFn(path string, info os.FileInfo, err error) error {
  21. for _,r := range regexps{
  22. if r.MatchString(path){
  23. fmt.Printf("[+] %s\n",path)
  24. }
  25. }
  26. return nil
  27. }

image.png