Skip to content

Commit

Permalink
F-Scrack.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mabangde committed Sep 18, 2019
1 parent 5f1b872 commit 48e3d0d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 23 deletions.
97 changes: 74 additions & 23 deletions golang/sqltool.go
Expand Up @@ -11,6 +11,7 @@ import (
)
/* Compile:
docker run --rm -it -v ${PWD}:/go golang:stretch env GO111MODULE=on GOPROXY=https://goproxy.io GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags -s -a -installsuffix cgo ms.go
upx -9 ms
*/
var (

Expand Down Expand Up @@ -76,7 +77,7 @@ func main() {
},
cli.BoolFlag{
Name: "enable,e",
Usage: "Enabled xp_cmd",
Usage: "Enabled xp_cmdshell",
},
}

Expand Down Expand Up @@ -148,23 +149,50 @@ func main() {
}
}


func exec_sql(){
stmt, err := conn.Prepare(query)
rows, err := conn.Query(query)
if err != nil {
log.Fatal("Prepare failed:", err.Error())

panic(err.Error())

}
defer stmt.Close()
defer rows.Close()

row := stmt.QueryRow()
//var somenumber int64
var result string
err = row.Scan( &result)
if err != nil {
log.Fatal("Query failed:", err.Error())
columns, err := rows.Columns()
if err !=nil{
panic(err.Error())
}
l(result)
}
values := make([]sql.RawBytes, len(columns))
scanArgs := make([]interface{}, len(values))
for i := range values {
scanArgs[i] = &values[i]
}

for rows.Next(){
err=rows.Scan(scanArgs...)
if err !=nil{
panic(err.Error())
}
var value string
for _,col := range values{
if col ==nil{
value=""
}else{
value=string(col)
}
fmt.Println(value)

}
//fmt.Println("-----------------------------------")

}
if err = rows.Err(); err != nil {
panic(err.Error()) // proper error handling instead of panic in your app
}
}





func Open() {
Expand Down Expand Up @@ -203,22 +231,45 @@ func main() {


func os_shell(){
stmt, err := conn.Prepare(`exec master..xp_cmdshell '` + cmd + `' `)
rows, err := conn.Query(`exec master..xp_cmdshell '` + cmd + `' `)
if err != nil {

log.Fatal("Prepare failed:\n", err.Error())
panic(err.Error())

}
defer stmt.Close()
defer rows.Close()

row := stmt.QueryRow()
//var somenumber int64
var result string
err = row.Scan( &result)
if err != nil {
log.Fatal("Exec failed:\n", err.Error())
columns, err := rows.Columns()
if err !=nil{
panic(err.Error())
}
values := make([]sql.RawBytes, len(columns))
scanArgs := make([]interface{}, len(values))
for i := range values {
scanArgs[i] = &values[i]
}

for rows.Next(){
err=rows.Scan(scanArgs...)
if err !=nil{
panic(err.Error())
}
var value string
for _,col := range values{
if col ==nil{
value=""
}else{
value=string(col)
}
fmt.Println(value)

}
//fmt.Println("-----------------------------------")

}
if err = rows.Err(); err != nil {
panic(err.Error()) // proper error handling instead of panic in your app
}
l(result)
}


Expand Down
Binary file removed linux/sqltool_amd64
Binary file not shown.
Binary file removed linux/sqltool_amd64_upx
Binary file not shown.
Binary file added linux/sqltool_amd64_upx.elf
Binary file not shown.

0 comments on commit 48e3d0d

Please sign in to comment.