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. WEB应用的常见安全漏洞

      01. SQL 注入 SQL 注入就是通过给 web 应用接口传入一些特殊字符,达到欺骗服务器执行恶意的 SQL 命令.SQL 注入漏洞属于后端的范畴,但前端也可做体验上的优化.原因:当使用外部不 ...

  2. 【JMeter_01】JMeter介绍与环境搭建

    JMeter介绍 Apache JMeter™应用开源软件,100%纯Java应用程序,设计之初是用于负载功能测试和性能测试.但因它在实现对各种接口的调用方面比较成熟,因此,常被用做接口功能测试. J ...

  3. 解除git文件处于lock状态方法

    解决办法: 去git文件夹下删除lock文件就可以

  4. 国内透明代理IP

  5. JavaWeb网上图书商城完整项目--25.注册页面之隐藏没有内容的错误信息实现

    在上一章中我们显示的效果如下所示: 上面后面都有错误的红色×的显示,这样是不对的,我们要解决该问题 我们要循环遍历每一个错误的信息,看它的内容有没有,如果有内容我们就显示错误的×,如果没有就不显示× ...

  6. Java 多线程基础(十一)线程优先级和守护线程

    Java 多线程基础(十一)线程优先级和守护线程 一.线程优先级 Java 提供了一个线程调度器来监控程序启动后进去就绪状态的所有线程.线程调度器通过线程的优先级来决定调度哪些线程执行.一般来说,Ja ...

  7. docx.opc.exceptions.PackageNotFoundError: Package not found at '文件名.docx' 问题解决

    编译源程序时,提示:docx.opc.exceptions.PackageNotFoundError: Package not found at '文件名.docx' . 源文件明明存在啊,难道是用的 ...

  8. linux环境搭建单机kafka

    准备工作: jdk-8u191-linux-x64.rpm  |   zookeeper-3.4.6.tar.gz  |   kafka_2.11-2.2.0.tgz 对应的地址 zookeeper: ...

  9. Flask项目实战:创建电影网站(2)

    flask网站制作后台时候常见流程总结 安利一个神神器: 百度脑图PC版 创建数据库 下面是创建User数据库,需要导入db库 #coding:utf8 from flask import Flask ...

  10. 洛谷 P3063 【[USACO12DEC]Milk Routing S】

    这道题可以暴力哒~ 我们枚举每一个出现过的容量,然后跑一次最短路,求延迟,在跑最短路的时候,如果遇到的某一个点,比我们当前枚举的那个点小,那么就直接不走这一个点,然后枚举完后,就能得到最大值了. 代码 ...