mirror of
https://codeberg.org/ultimateplayer1999/Golang-phish-update.git
synced 2024-10-31 22:18:45 -04:00
Compare commits
4 Commits
0ee5472332
...
06eb50358a
Author | SHA1 | Date | |
---|---|---|---|
06eb50358a | |||
75edc9fb79 | |||
e3bb9ddccb | |||
639ff3ceb7 |
1
LICENSE
1
LICENSE
@ -672,3 +672,4 @@ may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
|
@ -14,3 +14,5 @@ The following code is needed in a .env. This is for the DB connection.
|
||||
> DB_PASS=
|
||||
|
||||
This is based on the phish table. Table can also be changed if needed.
|
||||
|
||||
Execution time is *1h24m16.934194673s*. This was for **18811 records**.
|
||||
|
37
dbupdate.go
37
dbupdate.go
@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
|
||||
@ -33,6 +34,13 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Get the start time
|
||||
StartTime := time.Now()
|
||||
|
||||
// Format the start time
|
||||
formattedStartTime := StartTime.Format("02-01-2006 15:04:05")
|
||||
|
||||
fmt.Println("Script started at " + formattedStartTime)
|
||||
// Perform a cleanup on DB
|
||||
deleter, err := db.Exec("DELETE FROM phish;")
|
||||
if err != nil {
|
||||
@ -43,7 +51,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
|
||||
fmt.Printf("Deletion: Number of rows affected: %d\n", rowsAffected)
|
||||
|
||||
// Perform a cleanup on DB
|
||||
aiupdate, err := db.Exec("ALTER TABLE phish AUTO_INCREMENT = 0;")
|
||||
@ -55,7 +63,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
|
||||
fmt.Printf("Altering: Number of rows affected: %d\n", rowsAffected)
|
||||
|
||||
// Add local records first
|
||||
insert1, err := db.Exec("INSERT INTO phish (Domain, Reporter, Evidence) VALUES ('iriseperiplo.info', 'Henk', 'https://www.virustotal.com/gui/url/318ac29af0001f6678efdd94c16d3225d78369123ebbbe5f50387b208e0ac523?nocache=1');")
|
||||
@ -71,13 +79,13 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
|
||||
fmt.Printf("Insert: Number of rows affected: %d\n", rowsAffected)
|
||||
// Get the number of affected rows
|
||||
rowsAffected, err = insert2.RowsAffected()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
|
||||
fmt.Printf("Insert: Number of rows affected: %d\n", rowsAffected)
|
||||
|
||||
// Define name for use later
|
||||
// name := os.Getenv("USER_OR_BOTNAME")
|
||||
@ -95,6 +103,10 @@ func main() {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
currentTime := time.Now()
|
||||
formattedTime := currentTime.Format("02-01-2006 15:04:05")
|
||||
fmt.Println(formattedTime + ": Initial database table setup done")
|
||||
|
||||
fmt.Println("Status code: ", resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
@ -125,6 +137,23 @@ func main() {
|
||||
totalRowsAffected += rowsAffected
|
||||
}
|
||||
fmt.Printf("Total number of rows affected: %d\n", totalRowsAffected)
|
||||
|
||||
// Get the end time
|
||||
EndTime := time.Now()
|
||||
|
||||
// Format the end time
|
||||
formattedEndTime := EndTime.Format("02-01-2006 15:04:05")
|
||||
|
||||
fmt.Println("Recent changes recieved and has been added to the database. Removed domains deleted from database. Reorded domains.")
|
||||
|
||||
fmt.Println("Script ended at " + formattedEndTime)
|
||||
|
||||
// Calculate the time difference
|
||||
diff := EndTime.Sub(StartTime)
|
||||
|
||||
// Print the time difference
|
||||
fmt.Println("Time until completion: ", diff)
|
||||
|
||||
// dummy
|
||||
// fmt.Println("Data: ", string(body))
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user