Go Pentester - HTTP CLIENTS(1)
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)的更多相关文章
- Go Pentester - HTTP CLIENTS(5)
Parsing Document Metadata with Bing Scaping Set up the environment - install goquery package. https: ...
- Go Pentester - HTTP CLIENTS(4)
Interacting with Metasploit msf.go package rpc import ( "bytes" "fmt" "gopk ...
- Go Pentester - HTTP CLIENTS(3)
Interacting with Metasploit Early-stage Preparation: Setting up your environment - start the Metaspl ...
- Go Pentester - HTTP CLIENTS(2)
Building an HTTP Client That Interacts with Shodan Shadon(URL:https://www.shodan.io/) is the world' ...
- 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 ...
- 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 ...
- ZK 使用Clients.response
参考: http://stackoverflow.com/questions/11416386/how-to-access-au-response-sent-from-server-side-at-c ...
- MySQL之aborted connections和aborted clients
影响Aborted_clients 值的可能是客户端连接异常关闭,或wait_timeout值过小. 最近线上遇到一个问题,接口日志发现有很多超时报错,根据日志定位到数据库实例之后发现一切正常,一般来 ...
- 【渗透测试学习平台】 web for pentester -2.SQL注入
Example 1 字符类型的注入,无过滤 http://192.168.91.139/sqli/example1.php?name=root http://192.168.91.139/sqli/e ...
随机推荐
- Android学习笔记触摸事件
案例代码: activity_main.xml <?xml version="1.0" encoding="utf-8"?> <Relativ ...
- cb25a_c++_函数对象简介
cb25a_c++_函数对象简介预定义的函数对象https://blog.csdn.net/txwtech/article/details/104382505negate<type>()p ...
- 9.实战交付一套dubbo微服务到k8s集群(2)之Jenkins部署
1.下载Jenkins镜像打包上传harbor上 [root@hdss7- ~]# docker pull jenkins/jenkins:2.190. [root@hdss7- ~]# docker ...
- 6.kubernetes的GUI资源管理插件-dashboard
目录 1.准备dashboard镜像 2.创建资源配置清单 3.应用资源配置清单 4.查看创建的资源 5.解析域名 6.浏览器访问 7.令牌命令行获取方式 准备dashboard镜像 [root@hd ...
- 漏洞复现 MS11-003
0x01漏洞简介 ms11-003(windows7IE溢出攻击) 是利用IE8中对css的解析存在一个问题,导致任何访问包含非法css的页面将导致IE8崩溃重启的漏洞. 0x02环境准备 攻击机:k ...
- Git配置仓库的用户名邮箱
Git配置单个仓库的用户名邮箱 $ git config user.name "gitlab's Name" $ git config user.email "gitla ...
- java创建图片的缩略图
//java创建图片的缩略图private void createThumbnail(String filename, int thumbWidth, int thumbHeight, int qua ...
- elasticsearch中query和filter的区别
参考博客来自: https://mp.weixin.qq.com/s/tiiveCW3W-oDIgxvlwsmXA?utm_medium=hao.caibaojian.com&utm_sour ...
- 用VMware克隆CentOS 6.5如何进行网络设置
我们使用虚拟机的克隆工具克隆出了一个电脑,电脑连接采用nat方式 111电脑对于的ip地址设置如下 [root@localhost ~]# cd /etc/sysconfig/network-scri ...
- Spark HA搭建
正文 下载Spark版本,这版本又要求必须和jdk与hadoop版本对应. http://spark.apache.org/downloads.html tar -zxvf 解压到指定目录,进入con ...