Skip to content

Commit

Permalink
avoiding newline in output
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 committed Jul 22, 2021
1 parent d4de679 commit e4e29da
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cmd/interactsh-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,25 @@ func main() {
if *verbose {
builder.WriteString(fmt.Sprintf("\n-----------\nDNS Request\n-----------\n\n%s\n\n------------\nDNS Response\n------------\n\n%s\n\n", interaction.RawRequest, interaction.RawResponse))
}
writeOutput(outputFile, builder)
}
case "http":
if noFilter || *httpOnly {
builder.WriteString(fmt.Sprintf("[%s] Received HTTP interaction from %s at %s", interaction.FullId, interaction.RemoteAddress, interaction.Timestamp.Format("2006-01-02 15:04:05")))
if *verbose {
builder.WriteString(fmt.Sprintf("\n------------\nHTTP Request\n------------\n\n%s\n\n-------------\nHTTP Response\n-------------\n\n%s\n\n", interaction.RawRequest, interaction.RawResponse))
}
writeOutput(outputFile, builder)
}
case "smtp":
if noFilter || *smtpOnly {
builder.WriteString(fmt.Sprintf("[%s] Received SMTP interaction from %s at %s", interaction.FullId, interaction.RemoteAddress, interaction.Timestamp.Format("2006-01-02 15:04:05")))
if *verbose {
builder.WriteString(fmt.Sprintf("\n------------\nSMTP Interaction\n------------\n\n%s\n\n", interaction.RawRequest))
}
writeOutput(outputFile, builder)
}
}
if outputFile != nil {
_, _ = outputFile.Write(builder.Bytes())
_, _ = outputFile.Write([]byte("\n"))
}
gologger.Silent().Msgf("%s", builder.String())
} else {
b, err := jsonpkg.MarshalIndent(interaction, "", "\t")
if err != nil {
Expand All @@ -128,3 +126,11 @@ func main() {
os.Exit(1)
}
}

func writeOutput(outputFile *os.File, builder *bytes.Buffer) {
if outputFile != nil {
_, _ = outputFile.Write(builder.Bytes())
_, _ = outputFile.Write([]byte("\n"))
}
gologger.Silent().Msgf("%s", builder.String())
}

0 comments on commit e4e29da

Please sign in to comment.