Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cckuailong committed Oct 18, 2021
1 parent 89e55e4 commit 6e8238d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
main
result.txt
result.txt
.idea/vcs.xml
.idea/workspace.xml
14 changes: 13 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions core/hostscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func goScan(taskChan chan [2]string, wg *sync.WaitGroup){
result.Title = title
resultStr, _ := json.Marshal(result)
if len(title) > 0{
elog.Info(fmt.Sprintf("Uri: %s, Host: %s --> %s", uri, host, title))
elog.Notice(fmt.Sprintf("Uri: %s, Host: %s --> %s", uri, host, title))
utils.WriteLine(string(resultStr), *vars.OutFile)
}else{
elog.Warn(fmt.Sprintf("Uri: %s, Host: %s not reached", uri, host))
elog.Warn(fmt.Sprintf("Uri: %s, Host: %s No title found", uri, host))
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions utils/http.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
package utils

import (
"fmt"
"hostscan/elog"
"crypto/tls"
"hostscan/vars"
"io/ioutil"
"net/http"
"time"
)

func GetHttpBody(url, host string) string{
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: tr,
Timeout: time.Duration(*vars.Timeout) * time.Second,
}

reqest, err := http.NewRequest("GET", url, nil)

if err != nil {
elog.Error(fmt.Sprintf("DoGet: %s [%s]", url, err))
//elog.Error(fmt.Sprintf("DoGet: %s [%s]", url, err))
return ""
}

reqest.Header.Add("Host", host)
reqest.Host = host
reqest.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
response, err := client.Do(reqest)
if response != nil{
defer response.Body.Close()
}

if err != nil {
elog.Error(fmt.Sprintf("DoGet: %s [%s]", url, err))
//elog.Error(fmt.Sprintf("DoGet: %s [%s]", url, err))
return ""
}
bodyByte, _ := ioutil.ReadAll(response.Body)
Expand Down

0 comments on commit 6e8238d

Please sign in to comment.