示例#1
0
文件: main.go 项目: prinsmike/gopher
func main() {
	g := gopher.New()
	g.Start() // Start the gopher with default values

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.SetActivity(gopher.Wondering) // Changes the gophers activity

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.SetColor(gopher.Green)

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.SetPrefix("Hey yo!")

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.SetActivity(gopher.Boring)
	g.SetColor(gopher.Yellow) // Changes the gophers color
	g.SetPrefix("")
	g.SetSuffix("Whats up?")

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.SetActivity(gopher.Loving)
	g.SetColor(gopher.Magenta)
	g.SetPrefix(gopher.Loving.String())
	g.SetSuffix("")

	time.Sleep(8 * time.Second) // Run for some time to simulate work

	g.Stop()
}
示例#2
0
文件: main.go 项目: mattn/_gopher
func main() {

	g := gopher.New()
	g.Start() // Start the gopher

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.Activity = gopher.Wondering // Changes the gophers activity

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.Color = gopher.Green

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.Prefix = "Hey yo!"

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.Activity = gopher.Boring
	g.Color = gopher.Yellow // Changes the gophers color
	g.Prefix = ""
	g.Suffix = "Whats up?"

	time.Sleep(4 * time.Second) // Run for some time to simulate work

	g.Activity = gopher.Loving
	g.Color = gopher.Magenta
	g.Prefix = g.Activity.String()
	g.Suffix = ""

	time.Sleep(8 * time.Second) // Run for some time to simulate work

	g.Stop()
}
示例#3
0
文件: main.go 项目: gojhonny/pwnpaste
func main() {
	inputfilename := flag.String("i", "", "File containing new line delimited email addresses")
	ccount := flag.Int("c", 10, "Maximum number of concurrent requests")
	htmlOut := flag.Bool("html", false, "Output HTML (has webcache links)")
	showVersion := flag.Bool("v", false, "Print version and exit")
	flag.Parse()

	if *showVersion {
		fmt.Println(version)
		os.Exit(0)
	}

	emailAddrs := make(map[string]bool)

	if i := len(flag.Args()); i > 0 {
		for j := 0; j < i; j++ {
			emailAddrs[flag.Arg(j)] = true
		}
	}

	if *inputfilename != "" {
		f, err := os.Open(*inputfilename)

		if err != nil {
			fmt.Printf("[!] Error: %s", err.Error())
		}

		scanner := bufio.NewScanner(f)
		for scanner.Scan() {
			emailAddrs[scanner.Text()] = true
		}

		if err := scanner.Err(); err != nil {
			fmt.Printf("[!] Error: %s", err.Error())
		}

		f.Close()
	}

	results := []result{}

	// Mutex to protect writing in Goroutines.
	resultsMutex := sync.Mutex{}
	wg := sync.WaitGroup{}
	work := make(chan string, *ccount)

	g := gopher.New()

	if !*htmlOut {
		g.Start()
		g.SetSuffix(fmt.Sprintf("pwnpaste %v", version))
		g.SetColor(gopher.Green)
	}

	// Start up *ccount goroutine pool to make requests.
	for i := 0; i < *ccount; i++ {
		go func(j int) {
			for email := range work {
				pasteAccounts, _ := hibp.GetPasteAccount(email)
				if len(pasteAccounts) > 0 {
					pasteDatas := []pasteData{}

					for _, p := range pasteAccounts {
						pasteDatas = append(pasteDatas, pasteData{
							ID:             p.ID,
							PasteBinLink:   fmt.Sprintf("https://pastebin.com/raw.php?i=%s", p.ID),
							CachedViewLink: fmt.Sprintf("https://webcache.googleusercontent.com/search?q=cache:https://pastebin.com/%s", p.ID),
						})
					}
					resultsMutex.Lock()
					results = append(results, result{
						Email:  email,
						Pastes: pasteDatas,
					})
					if !*htmlOut {
						if j%2 == 0 {
							g.SetColor(gopher.Magenta)
							g.SetActivity(gopher.Loving)
						} else {
							g.SetColor(gopher.Green)
							g.SetActivity(gopher.Boring)
						}
					}
					resultsMutex.Unlock()
				}
				wg.Done()
			}
		}(i)
	}

	// Send each email to the goroutine pool
	for email := range emailAddrs {
		wg.Add(1)
		work <- email
	}
	close(work)

	wg.Wait()
	g.Stop()

	if *htmlOut {
		outputHTML(results)
	} else {
		outputTable(results)
	}

}