Author SHA1 Message Date
Mike Holloway 3c420dc3db Whoops, > -> < 2021-06-28 00:15:21 -04:00
Mike Holloway 54b52273da On branch pseudocode
Changes to be committed:
	modified:   main.go
		Due tomorrow, only a few hours found for this project, so
		the choice to flesh out ideas in pseudocode was made.
2021-06-28 00:11:40 -04:00
Mike Holloway 93fd6f916b On branch timer
Changes to be committed:
	modified:   main.go
		Arrays for each line of the tcp file.
2021-06-26 17:11:23 -04:00
Mike Holloway 8e2f4e3db8 On branch timer
Changes to be committed:
	modified:   main.go
		Adding use of time package directly
	modified:   timer/timer.go
		Simplifying this away.
2021-06-26 17:07:48 -04:00
Mike Holloway bb77957ed4 On branch master
Changes to be committed:
	modified:   main.go
		Adding '_' to characters ignored by regex replace.
2021-06-26 13:00:58 -04:00
Mike Holloway a46c855960 On branch timer
Changes to be committed:
	modified:   main.go
		Add call to timer
	new file:   timer/timer.go
		New 10 second timer
2021-06-25 00:20:30 -04:00
Mike Holloway 0ea14fd132 On branch fix-colons
Changes to be committed:
	modified:   main.go
		No longer replacing colons with ','
2021-06-24 23:01:12 -04:00
Mike Holloway 7020adee58 On branch hexadecimal-and-fields
Changes to be committed:
	modified:   .gitignore
		Added binary file
2021-06-24 22:26:52 -04:00
Mike Holloway 399459c744 modified: main.go
Functions:
			hexadecimal handling
			whitespace management
			csv-like interpolation
	Next steps:
		Create map of key-value pairs using column headers
		Iterate hex conversion fucntions across values
		Track changes every 10 minutes using loop with timestamp
		Report changes to the console
2021-06-24 22:14:25 -04:00
Mike Holloway b4b01a5cf4 On branch read-file-error-check
Changes to be committed:
	new file:   main
		Perhaps add this to gitignore next time? Is it generally bad form?
	new file:   main.go
2021-06-17 01:50:06 -04:00
3 changed files with 80 additions and 1 deletions

No files matched your search

Executable
BIN
View File
Binary file not shown.
+45 -1
View File
@@ -1,5 +1,9 @@
package main package main
import ( import (
"reflect"
//"./timer"
"time"
"fmt" "fmt"
"strings" "strings"
"regexp" "regexp"
@@ -8,7 +12,10 @@ import (
) )
var tcp_data string = read_tcp_file("/proc/net/tcp")
func main() { func main() {
var loops int = 0
// How to split on space-delimited fields, then colon-delimited fields? // How to split on space-delimited fields, then colon-delimited fields?
// How to turn this byte into a string? // How to turn this byte into a string?
@@ -16,7 +23,28 @@ func main() {
// and then converted byte by byte (2 char at a time) // and then converted byte by byte (2 char at a time)
//fmt.Println(convert_address(reverse_string(reverse_bytes("0100007F")))) //fmt.Println(convert_address(reverse_string(reverse_bytes("0100007F"))))
read_tcp_file("/proc/net/tcp") for _ = range time.Tick(10 * time.Second) {
fmt.Println("Waiting 10 seconds...")
for num, row := range get_tcp_rows(tcp_data) {
row_type := reflect.TypeOf(row)
fmt.Println(num, " ", row_type)
}
// if loops modulo 6 (1min) then
// for address in address_list do
// if (grep address address_list | wc -l >=3) then
// This is a port scan!
// fi
// done
// elseif (wc -l old_tcp_file < wc -l tcp_file) then
// for i in (wc -l tcp_file - wc -l old_tcp_flle) do
// print New Connection! reverse_strng(reverse_bytes(tcp_file[i])) // This oversimplifies row value selection for the sake
// // of pseudocode
// done
// else
// "No new connections. Waiting another 10 seconds..."
// fi
loops++
}
} }
func check(e error) { func check(e error) {
@@ -25,6 +53,22 @@ func check(e error) {
} }
} }
// Aiming for an array of [string]string maps
// Am I looking for a map[string]interface here?
func get_tcp_rows(connections_file string) []string {
tcp_lines := strings.Split(connections_file, "\n")
regexpression := regexp.MustCompile(`[\r\n\t\f\v]+`)
tcp_columns := regexpression.Split(tcp_lines[0], -1)
var tcp_values map[string]string
for i, line := range tcp_lines[1:] {
trim_line := strings.TrimSpace(line)
values := regexpression.Split(trim_line, -1)
column := tcp_columns[i]
tcp_values[column] = values
}
return tcp_values
}
// Take a string, create a rune slice, and use a loop to reverse it character-wise. // Take a string, create a rune slice, and use a loop to reverse it character-wise.
func reverse_bytes(s string) string { func reverse_bytes(s string) string {
+35
View File
@@ -0,0 +1,35 @@
package timer
import (
"fmt"
"time"
//"reflect"
)
func New(duration_int int, unit string) *time.Timer {
start := time.NewTimer(0)
duration := time.Duration(duration_int)
// fmt.Println(reflect.TypeOf(duration))
// timer_10s := time.NewTimer(10 * time.Second)
// timer_1m := time.NewTimer(1 * time.Minute)
fmt.Println("Duration: ", duration_int, "Unit: ", unit, ".")
if unit == "Second" {
start = time.NewTimer(duration * time.Second)
} else if unit == "Minute" {
start = time.NewTimer(duration * time.Minute)
} else {
fmt.Println("Unit not recognized.")
}
fmt.Println("Waiting ", duration_int, " ", unit, ".")
if start.Stop() {
<-start.C
fmt.Println("Done waiting ", duration_int, " ", unit, "!")
}
return start
// for elapsed < ten_seconds {
//}
// for
}
func Reset