• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gryffin.Scan类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/yahoo/gryffin.Scan的典型用法代码示例。如果您正苦于以下问题:Golang Scan类的具体用法?Golang Scan怎么用?Golang Scan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Scan类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: extract

func (r *PhantomJSRenderer) extract(stdout io.ReadCloser, s *gryffin.Scan) {

	defer close(r.done)

	dec := json.NewDecoder(stdout)
	for {
		var m message
		err := dec.Decode(&m)
		if err == io.EOF {
			return
		} else {
			if m.responseMessage != nil {
				m.Response.fill(s)
				if s.IsDuplicatedPage() {
					return
				}

				r.chanResponse <- s
				for _, link := range m.Response.Details.Links {
					if newScan := link.toScan(s); newScan != nil && newScan.IsScanAllowed() {
						r.chanLinks <- newScan
					}
				}
			} else if m.domMessage != nil {
				for _, link := range m.domMessage.Links {
					if newScan := link.toScan(s); newScan != nil && newScan.IsScanAllowed() {
						r.chanLinks <- newScan
					}
				}
			}
		}
	}

}
开发者ID:barseghyanartur,项目名称:gryffin,代码行数:34,代码来源:phantomjs.go


示例2: extract

func (r *PhantomJSRenderer) extract(stdout io.ReadCloser, s *gryffin.Scan) {

	defer close(r.done)

	dec := json.NewDecoder(stdout)
	for {
		var m message
		err := dec.Decode(&m)
		if err == io.EOF {
			return
		} else {
			if m.responseMessage != nil {
				m.Response.fill(s)
				if s.IsDuplicatedPage() {
					return
				}
				r.chanResponse <- s
				r.parseDetails(&m.Response.Details, s)
			}

			if m.details != nil {
				r.parseDetails(m.details, s)
			}
		}
	}
}
开发者ID:rahmiyildiz,项目名称:gryffin,代码行数:26,代码来源:phantomjs.go


示例3: toScan

func (l *link) toScan(parent *gryffin.Scan) *gryffin.Scan {
	if req, err := http.NewRequest("GET", l.Url, nil); err == nil {
		s := parent.Spawn()
		s.MergeRequest(req)
		return s
	}
	// invalid url
	return nil
}
开发者ID:barseghyanartur,项目名称:gryffin,代码行数:9,代码来源:phantomjs.go


示例4: Fuzz

func (s *Fuzzer) Fuzz(g *gryffin.Scan) (count int, err error) {

	cmd := exec.Command("echo", g.Request.URL.Host)
	_, err = cmd.Output()

	g.Logm("Dummy.Scan", fmt.Sprintf("Echo return %t", cmd.ProcessState.Success()))
	return 0, err

}
开发者ID:buglloc,项目名称:gryffin,代码行数:9,代码来源:dummy.go


示例5: extract

func (s *Fuzzer) extract(g *gryffin.Scan, output string) (count int) {

	for _, l := range strings.Split(output, "\n") {
		l = strings.TrimSpace(l)
		switch {
		case strings.HasPrefix(l, "[~] Affected page"):
			g.Logm("Arachni.Findings", l)
			count++
		}
	}

	return
}
开发者ID:buglloc,项目名称:gryffin,代码行数:13,代码来源:arachni.go


示例6: Do

func (r *PhantomJSRenderer) Do(s *gryffin.Scan) {

	r.chanResponse = make(chan *gryffin.Scan, 10)
	r.chanLinks = make(chan *gryffin.Scan, 10)
	r.done = make(chan string)

	// Construct the command.
	// render.js http(s)://<host>[:port][/path] [{"method":"post", "data":"a=1&b=2"}]
	url := s.Request.URL.String()
	cookies := make([]string, 0)
	// ua := s.Request.UserAgent()
	ua := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"

	for _, c := range s.Cookies {
		cookies = append(cookies, c.String())
	}

	arg := input{
		Method: s.Request.Method,
		Headers: inputHeaders{
			UserAgent: ua,
			Cookie:    strings.Join(cookies, ";"),
		},
	}

	opt, err := json.Marshal(arg)
	if err != nil {
		s.Error("PhantomjsRenderer.Do", err)
		return
	}

	// s.Logmf("PhantomjsRenderer.Do", "Running: render.js %s '%s'", url, string(opt))
	s.Logmf("PhantomjsRenderer.Do", "Running: render.js")

	cmd := exec.Command(
		os.Getenv("GOPATH")+"/src/github.com/yahoo/gryffin/renderer/resource/render.js",
		url,
		string(opt))

	stdout, err := cmd.StdoutPipe()
	if err != nil {
		s.Error("PhantomjsRenderer.Do", err)
		return
	}

	if err := cmd.Start(); err != nil {
		s.Error("PhantomjsRenderer.Do", err)
		return
	}

	r.process = cmd.Process

	// wait until done or timeout.
	go r.extract(stdout, s)
	go r.wait(s)

	cmd.Wait()

}
开发者ID:binarydreams,项目名称:gryffin,代码行数:59,代码来源:phantomjs.go


示例7: Fuzz

func (s *Fuzzer) Fuzz(g *gryffin.Scan) (count int, err error) {

	var cookies []string
	// for _, c := range g.CookieJar.Cookies(g.Request.URL) {
	for _, c := range g.Cookies {
		cookies = append(cookies, c.String())
	}

	args := []string{
		"--checks", "xss*",
		"--output-only-positives",
		"--http-request-concurrency", "1",
		"--http-request-timeout", "10000",
		"--timeout", "00:03:00",
		"--scope-dom-depth-limit", "0",
		"--scope-directory-depth-limit", "0",
		"--scope-page-limit", "1",
		"--audit-with-both-methods",
		"--report-save-path", "/dev/null",
		"--snapshot-save-path", "/dev/null",
	}

	// TODO: Post method

	// Cookie
	if len(cookies) > 0 {
		args = append(args, "--http-cookie-string", strings.Join(cookies, ";"))
	}

	args = append(args, g.Request.URL.String())

	cmd := exec.Command("arachni", args...)

	g.Logm("Arachni.Scan", fmt.Sprintf("Run as %s", cmd.Args))

	output, err := cmd.Output()

	count = s.extract(g, string(output))

	if err != nil {
		return
	}

	g.Logm("Arachni.Scan", fmt.Sprintf("Arachni return %t", cmd.ProcessState.Success()))
	return

}
开发者ID:buglloc,项目名称:gryffin,代码行数:47,代码来源:arachni.go


示例8: toScan

func (f *form) toScan(parent *gryffin.Scan) *gryffin.Scan {
	m := strings.ToUpper(f.Method)
	u := f.Url
	var r io.Reader
	if m == "POST" {
		r = ioutil.NopCloser(strings.NewReader(f.Data))
	} else {
		u += "&" + f.Data
	}

	if req, err := http.NewRequest(m, u, r); err == nil {
		s := parent.Spawn()
		s.MergeRequest(req)
		return s
	}
	// invalid url
	return nil
}
开发者ID:rahmiyildiz,项目名称:gryffin,代码行数:18,代码来源:phantomjs.go


示例9: fill

func (m *response) fill(s *gryffin.Scan) {

	/*
	   {"response":{"headers":{"Date":["Thu, 30 Jul 2015 00:13:43 GMT"],"Set-Cookie":["B=82j3nrdarir1n&b=3&s=23; expires=Sun, 30-Jul-2017 00:13:43 GMT; path=/; domain=.yahoo.com"]

	*/
	resp := &http.Response{
		Request:    s.Request,
		StatusCode: m.Status,
		Status:     strconv.FormatInt(int64(m.Status), 10),
		Proto:      "HTTP/1.1",
		ProtoMajor: 1,
		ProtoMinor: 1,
		Header:     m.Headers,
		Body:       noCloseReader{strings.NewReader(m.Body)},
	}

	s.Response = resp
	s.ReadResponseBody()

}
开发者ID:barseghyanartur,项目名称:gryffin,代码行数:21,代码来源:phantomjs.go


示例10: kill

func (r *PhantomJSRenderer) kill(reason string, s *gryffin.Scan) {
	if err := r.process.Kill(); err == nil {
		s.Logmf("PhantomjsRenderer.Do", "[%s] Terminating the crawl process.", reason)
	}
}
开发者ID:barseghyanartur,项目名称:gryffin,代码行数:5,代码来源:phantomjs.go


示例11: Do

func (r *PhantomJSRenderer) Do(s *gryffin.Scan) {

	r.chanResponse = make(chan *gryffin.Scan, 10)
	r.chanLinks = make(chan *gryffin.Scan, 10)

	// Construct the command.
	// render.js http(s)://<host>[:port][/path] [{"method":"post", "data":"a=1&b=2"}]
	url := s.Request.URL.String()
	cookies := make([]string, 0)
	// ua := s.Request.UserAgent()
	ua := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"

	for _, c := range s.Cookies {
		cookies = append(cookies, c.String())
	}

	arg := input{
		Method: s.Request.Method,
		Headers: inputHeaders{
			UserAgent: ua,
			Cookie:    strings.Join(cookies, ";"),
		},
	}

	opt, err := json.Marshal(arg)
	if err != nil {
		s.Error("PhantomjsRenderer.Do", err)
		return
	}

	// s.Logmf("PhantomjsRenderer.Do", "Running: render.js %s '%s'", url, string(opt))
	s.Logmf("PhantomjsRenderer.Do", "Running: render.js")

	cmd := exec.Command(
		os.Getenv("GOPATH")+"/src/github.com/yahoo/gryffin/renderer/resource/render.js",
		url,
		string(opt))

	stdout, err := cmd.StdoutPipe()
	if err != nil {
		s.Error("PhantomjsRenderer.Do", err)
		return
	}

	if err := cmd.Start(); err != nil {
		s.Error("PhantomjsRenderer.Do", err)
		return
	}

	kill := func(reason string) {
		if err := cmd.Process.Kill(); err != nil {
			// TODO - forgive "os: process already finished"
			s.Error("PhantomjsRenderer.Do", err)
			// log.Printf("error: %s", err)
		} else {
			s.Logmf("PhantomjsRenderer.Do", "[%s] Terminating the crawl process.", reason)
		}
	}
	// Kill when timeout
	_ = time.Second
	if r.Timeout != 0 {
		timeout := func() {
			<-time.After(time.Duration(r.Timeout) * time.Second)
			kill("Timeout")
		}
		go timeout()
	}

	crawl := func() {
		defer close(r.chanResponse)
		defer close(r.chanLinks)

		dec := json.NewDecoder(stdout)

		for {
			var m message
			err := dec.Decode(&m)
			if err == io.EOF {
				return
				break
			} else {
				if m.responseMessage != nil {
					m.Response.fill(s)
					if s.IsDuplicatedPage() {
						kill("Duplicated")
						return
					}
					s.Logm("PhantomjsRenderer.Do.UniqueCrawl", m.MsgType)
					r.chanResponse <- s
					for _, link := range m.Response.Details.Links {
						if newScan := link.toScan(s); newScan != nil && newScan.IsScanAllowed() {
							r.chanLinks <- newScan
						}
					}
				} else if m.domMessage != nil {
					for _, link := range m.domMessage.Links {
						if newScan := link.toScan(s); newScan != nil && newScan.IsScanAllowed() {
							r.chanLinks <- newScan
						}
					}
//.........这里部分代码省略.........
开发者ID:0xwindows,项目名称:gryffin,代码行数:101,代码来源:phantomjs.go


示例12: Fuzz

func (s *Fuzzer) Fuzz(g *gryffin.Scan) (count int, err error) {

	var cookies []string

	// for _, c := range g.CookieJar.Cookies(g.Request.URL) {
	for _, c := range g.Cookies {
		cookies = append(cookies, c.String())
	}

	args := []string{
		"--batch",
		"--timeout=2",
		"--retries=3",
		"--crawl=0",
		"--disable-coloring",
		"-o",
		"--text-only",
		// "--threads=4",
		"-v", "0",
		"--level=1",
		"--risk=1",
		"--smart",
		"--fresh-queries",
		"--purge-output",
		"--os=Linux",
		"--dbms=MySQL",
		"--delay=0.1",
		"--time-sec=1",
	}

	// TODO: Post method
	// if g.RequestBody != "" {
	// args = append(args, fmt.Sprintf("--data=..."
	// }

	// only for integer based injection.
	var testable []string
	for k, vs := range g.Request.URL.Query() {
		for _, v := range vs {
			_, err := strconv.ParseInt(v, 10, 64)
			if err == nil {
				// query param value is an integer
				testable = append(testable, k)
			}
		}
	}
	if len(testable) > 0 {
		args = append(args, "-p", strings.Join(testable, ","))
	}

	// Cookie
	if len(cookies) > 0 {
		fmt.Println(cookies)
		args = append(args, "--cookie", strings.Join(cookies, ";"))
	}

	args = append(args, "-u", g.Request.URL.String())

	cmd := exec.Command("sqlmap", args...)

	g.Logm("SQLMap.Scan", fmt.Sprintf("Run as %s", cmd.Args))

	output, err := cmd.Output()

	if err != nil {
		return
	}

	count = s.extract(g, string(output))

	g.Logm("SQLMap.Scan", fmt.Sprintf("SQLMap return %t", cmd.ProcessState.Success()))
	return

}
开发者ID:buglloc,项目名称:gryffin,代码行数:74,代码来源:sqlmap.go


示例13: Do

func (r *NoScriptRenderer) Do(s *gryffin.Scan) {
	r.chanResponse = make(chan *gryffin.Scan, 10)
	r.chanLinks = make(chan *gryffin.Scan, 10)

	crawl := func() {

		defer close(r.chanResponse)
		defer close(r.chanLinks)

		client := &http.Client{}

		client.Timeout = time.Duration(3) * time.Second

		if response, err := client.Do(s.Request); err == nil {
			s.Response = response
		} else {
			s.Logm("NoScriptRenderer", fmt.Sprintf("error in building request: %s", err))
			return
		}

		s.ReadResponseBody()

		if s.IsDuplicatedPage() {
			return
		}

		tokenizer := html.NewTokenizer(strings.NewReader(s.ResponseBody))

		r.chanResponse <- s

		for {
			t := tokenizer.Next()

			switch t {

			case html.ErrorToken:
				return

			case html.StartTagToken:
				token := tokenizer.Token()
				if token.DataAtom.String() == "a" {
					for _, attr := range token.Attr {
						if attr.Key == "href" {
							link := s.Spawn()
							// TODO - we drop relative URL as it would drop "#".
							// Yet, how about real relative URLs?
							if req, err := http.NewRequest("GET", attr.Val, nil); err == nil {
								if true {
									// || req.URL.IsAbs() {
									link.MergeRequest(req)
									if link.IsScanAllowed() {
										r.chanLinks <- link
									}
								} else {
									// ignore relative URL. TOFIX.
								}
							} else {
								log.Printf("error in building request: %s", err)
							}
						}
					}
				}
			}
		}

		// parse and find links.

	}

	go crawl()

	return
}
开发者ID:buglloc,项目名称:gryffin,代码行数:73,代码来源:noscript.go



注:本文中的github.com/yahoo/gryffin.Scan类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang utils.PromiseCtx函数代码示例发布时间:2022-05-28
下一篇:
Golang proto.EncodedProfile类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap