Building HTTP Clients that interact with a variety of security tools and resources.

Basic Preparation:

Go's net/HTTP standard package contains several convenience functions to quickly and easily send POST, GET, and HEAD requests, which are arguably the most common HTTP verbs you'll use.

Get(url string) (resp *Response, err error)
Head(url string) (resp *Response, err error)
Post(url string, bodyType string, body io.Reader) (resp *Response, err error)

Additional POST request, called PostForm()

func POSTFORM(url string, data url.Values) (resp *Response, err error)

No convenience functions exist for other HTTP verbs, such as PATCH, PUT, or DELETE. Use these verbs to interact with RESTful APIs.

Generate a Request using the NewRequest() function.

func NewRequest(methond, url string, body io.Reader) (resp *Response, err error)

Uses the ioutil.ReadAll() function to read data from the response body.

package main

import (
"fmt"
"io/ioutil"
"log"
"net/http"
) func main() {
resp, err := http.Get("http://www.bing.com/robots.txt")
if err != nil {
log.Panicln(err)
}
// Print HTTP Status
fmt.Println(resp.Status) //Read and display response body
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Panicln(err)
}
fmt.Println(string(body))
resp.Body.Close()
}

Structured Response Parsing

JSON file

{"Message": "All is good with the world","Status": "Success"}

Go Parsing codes

package main

import (
"encoding/json"
"log"
"net/http"
) type Status struct {
Message string
Status string
} func main() {
res, err := http.Post(
"http://IP:PORT/ping",
"application/json",
nil,
)
if err != nil {
log.Fatalln(err)
} var status Status
if err := json.NewDecoder(res.Body).Decode(&status); err != nil {
log.Fatalln(err)
}
defer res.Body.Close()
log.Printf("%s -> %s\n", status.Status, status.Message)
}

  

Go Pentester - HTTP CLIENTS(1)的更多相关文章

  1. Go Pentester - HTTP CLIENTS(5)

    Parsing Document Metadata with Bing Scaping Set up the environment - install goquery package. https: ...

  2. Go Pentester - HTTP CLIENTS(4)

    Interacting with Metasploit msf.go package rpc import ( "bytes" "fmt" "gopk ...

  3. Go Pentester - HTTP CLIENTS(3)

    Interacting with Metasploit Early-stage Preparation: Setting up your environment - start the Metaspl ...

  4. Go Pentester - HTTP CLIENTS(2)

    Building an HTTP Client That Interacts with Shodan Shadon(URL:https://www.shodan.io/)  is the world' ...

  5. Creating a radius based VPN with support for Windows clients

    This article discusses setting up up an integrated IPSec/L2TP VPN using Radius and integrating it wi ...

  6. Deploying JRE (Native Plug-in) for Windows Clients in Oracle E-Business Suite Release 12 (文档 ID 393931.1)

    In This Document Section 1: Overview Section 2: Pre-Upgrade Steps Section 3: Upgrade and Configurati ...

  7. ZK 使用Clients.response

    参考: http://stackoverflow.com/questions/11416386/how-to-access-au-response-sent-from-server-side-at-c ...

  8. MySQL之aborted connections和aborted clients

    影响Aborted_clients 值的可能是客户端连接异常关闭,或wait_timeout值过小. 最近线上遇到一个问题,接口日志发现有很多超时报错,根据日志定位到数据库实例之后发现一切正常,一般来 ...

  9. 【渗透测试学习平台】 web for pentester -2.SQL注入

    Example 1 字符类型的注入,无过滤 http://192.168.91.139/sqli/example1.php?name=root http://192.168.91.139/sqli/e ...

随机推荐

  1. DES 加密解密 文件工具类

    public class DESEncrypt { /** 加密工具 */ private Cipher encryptCipher = null; /** 解密工具 */ private Ciphe ...

  2. CentOS快速安装Nginx的方法,nginx如何启动重启停止

    1.防止 make: command not found,提前安装一些插件,取决于当前环境是否已安装,如果已经安装就不需要执行此命令 yum -y install gcc automake autoc ...

  3. Springboot基于assembly的服务化打包

    (1)首先我们编辑 assembly.xml 配置文件,在前文的基础上新增第三方依赖设置(高亮部分),实现将第三方的 jar 包添加到压缩包里的 lib 目录: <?xml version=&q ...

  4. Java-CORBA

    本文HelloCorba参考 Getting Started with JavaTM IDL 说在前面 Java TM IDL is a technology for distributed obje ...

  5. dart快速入门教程 (7.3)

    7.4.抽离类为单独文件 新建一个文件,单独存放一个类,例如:Person类抽离到person.dart文件中 class Person { final String name; final num ...

  6. 双缓冲显示字幕(卡拉ok字幕)

    思路: 1.设置定时器SetTime,在Ontime()里面确定显示矩形的大小,让后用DrawText把字铁道矩形上面: 2. int nTextHei = dc.GetTextExtent( m_s ...

  7. 【未完待续】MVC 之HTML辅助方法

    顾名思义,HTML辅助方法(HTML Helper)就是用来辅助产生HTML之用, 在开发View的时候一定会面对许多HTML标签,处理这些HTML的工作非常繁琐,为了降低View的复杂度,可以使用H ...

  8. 【Spring】原来SpringBoot是这样玩的

    菜瓜:我自己去调Mvc的源码差点没给Spring的逻辑秀死...难受 水稻:那今天咱们看一个简单易用的SpringBoot吧 菜瓜:可以,这个我熟悉 水稻:熟悉? 菜瓜:当我没说,请开始你的表演 水稻 ...

  9. Dynamics CRM 365 不用按钮工具,直接用js脚本控制按钮的显示隐藏

    Dynamics CRM 365 不用按钮工具,直接用js脚本控制按钮的显示隐藏: try { // 转备案按钮 let transferSpecialRequestButton = parent.p ...

  10. Zookeeper 序列化

    读完这篇文章你将会收获到 在 Zookeeper 源码项目中新建模块,使用 Jute 进行序列化和反序列化 修改 Jute 中的 buffer size 来序列化/反序列化大对象 序言 从 前面的文章 ...