Skip to content

Commit

Permalink
removed the use of deprecated package
Browse files Browse the repository at this point in the history
  • Loading branch information
h4ck3r-04 committed Jun 22, 2024
1 parent 94f13a3 commit 5c6acd5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions agents/url_requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package agents

import (
"fmt"
"io/ioutil"
"io"
"os"
"strings"

Expand Down Expand Up @@ -105,7 +105,7 @@ func (a *URLRequester) writeHeaders(page *core.Page) {
for _, header := range page.Headers {
headers += fmt.Sprintf("%v: %v\n", header.Name, header.Value)
}
if err := ioutil.WriteFile(a.session.GetFilePath(filepath), []byte(headers), 0644); err != nil {
if err := os.WriteFile(a.session.GetFilePath(filepath), []byte(headers), 0644); err != nil {
a.session.Out.Debug("[%s] Error: %v\n", a.ID(), err)
a.session.Out.Error("Failed to write HTTP response headers for %s to %s\n", page.URL, a.session.GetFilePath(filepath))
}
Expand All @@ -114,14 +114,14 @@ func (a *URLRequester) writeHeaders(page *core.Page) {

func (a *URLRequester) writeBody(page *core.Page, resp gorequest.Response) {
filepath := fmt.Sprintf("html/%s.html", page.BaseFilename())
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
a.session.Out.Debug("[%s] Error: %v\n", a.ID(), err)
a.session.Out.Error("Failed to read response body for %s\n", page.URL)
return
}

if err := ioutil.WriteFile(a.session.GetFilePath(filepath), body, 0644); err != nil {
if err := os.WriteFile(a.session.GetFilePath(filepath), body, 0644); err != nil {
a.session.Out.Debug("[%s] Error: %v\n", a.ID(), err)
a.session.Out.Error("Failed to write HTTP response body for %s to %s\n", page.URL, a.session.GetFilePath(filepath))
}
Expand Down
5 changes: 2 additions & 3 deletions core/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"path"
Expand Down Expand Up @@ -233,7 +232,7 @@ func (s *Session) GetFilePath(p string) string {
}

func (s *Session) ReadFile(p string) ([]byte, error) {
content, err := ioutil.ReadFile(s.GetFilePath(p))
content, err := os.ReadFile(s.GetFilePath(p))
if err != nil {
return content, err
}
Expand All @@ -247,7 +246,7 @@ func (s *Session) ToJSON() string {

func (s *Session) SaveToFile(filename string) error {
path := s.GetFilePath(filename)
err := ioutil.WriteFile(path, []byte(s.ToJSON()), 0644)
err := os.WriteFile(path, []byte(s.ToJSON()), 0644)
if err != nil {
return err
}
Expand Down
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -69,7 +68,7 @@ func main() {
sess.Out.Important("%s v%s started at %s\n\n", core.Name, core.Version, sess.Stats.StartedAt.Format(time.RFC3339))

if *sess.Options.SessionPath != "" {
jsonSession, err := ioutil.ReadFile(*sess.Options.SessionPath)
jsonSession, err := os.ReadFile(*sess.Options.SessionPath)
if err != nil {
sess.Out.Fatal("Unable to read session file at %s: %s\n", *sess.Options.SessionPath, err)
os.Exit(1)
Expand All @@ -85,7 +84,7 @@ func main() {
sess.Out.Important("Generating HTML report...")
var template []byte
if *sess.Options.TemplatePath != "" {
template, err = ioutil.ReadFile(*sess.Options.TemplatePath)
template, err = os.ReadFile(*sess.Options.TemplatePath)
} else {
template, err = sess.Asset("static/report_template.html")
}
Expand Down Expand Up @@ -216,7 +215,7 @@ func main() {
sess.Out.Important("Generating HTML report...")
var template []byte
if *sess.Options.TemplatePath != "" {
template, err = ioutil.ReadFile(*sess.Options.TemplatePath)
template, err = os.ReadFile(*sess.Options.TemplatePath)
} else {
template, err = sess.Asset("static/report_template.html")
}
Expand Down
3 changes: 1 addition & 2 deletions parsers/nmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parsers

import (
"io"
"io/ioutil"

"github.com/h4ck3r-04/aquatone/core"

Expand All @@ -17,7 +16,7 @@ func NewNmapParser() *NmapParser {

func (p *NmapParser) Parse(r io.Reader) ([]string, error) {
var targets []string
bytes, err := ioutil.ReadAll(r)
bytes, err := io.ReadAll(r)
if err != nil {
return targets, err
}
Expand Down

0 comments on commit 5c6acd5

Please sign in to comment.