Skip to content

Instantly share code, notes, and snippets.

View abhaybhargav's full-sized avatar

Abhay Bhargav abhaybhargav

  • we45
  • All over the world
View GitHub Profile
@abhaybhargav
abhaybhargav / login.js
Created April 14, 2018 14:04
The "after" test hook. Once the test is done. The after hook in nightwatch is triggered. This is where ZAP does its scanning and reporting
after: function(client, done) {
//Browser closes here
client.end(function() {
done();
});
let scan_id;
let scan_status = 0;
//ZAP Scan Starts here
setTimeout(() => {
axios.post(zapApi, {
@abhaybhargav
abhaybhargav / zap_manager.js
Created April 14, 2018 14:04
ZAP Manager Program to manage start and stop ops for ZAP
module.exports.startZap = async function(done) {
await axios.post(zapApi, {
method: "start_zap_scanner",
jsonrpc: "2.0",
id: 0
})
.then(res => {
console.log(res.data);
})
.catch(err => {
@abhaybhargav
abhaybhargav / login.js
Created April 16, 2018 13:34
Nightwatch Tests
"Login to weCare App": function(client) {
client
.url(client.launchUrl + "/login/")
.waitForElementVisible("body",1000)
.assert.visible("input[type=email]")
.assert.visible("input[type=password]")
.setValue("input[type=email]", '[email protected]')
.setValue("input[type=password]", 'secdevops')
.click("button[id=submit]")
.waitForElementVisible("body",1000)
@abhaybhargav
abhaybhargav / instance.tf
Created June 15, 2018 07:33
terraform ec2 deploy + install inspector agent
resource "aws_key_pair" "inspectkey" {
public_key = "${file(var.PATH_TO_PUB_KEY)}"
}
resource "aws_instance" "inspector-instance" {
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
instance_type = "m1.small"
key_name = "${aws_key_pair.inspectkey.key_name}"
security_groups = ["inspect"]
@abhaybhargav
abhaybhargav / instance.tf
Created June 15, 2018 07:38
Amazon Inspector Generate Rules
resource "aws_inspector_resource_group" "bar" {
tags {
Name = "${aws_instance.inspector-instance.tags.Name}"
}
}
resource "aws_inspector_assessment_target" "myinspect" {
name = "inspector-instance-assessment"
resource_group_arn = "${aws_inspector_resource_group.bar.arn}"
}
@abhaybhargav
abhaybhargav / scan_dynamo.py
Created June 28, 2018 12:53
DynamoDB Scan Operation
client.scan(TableName = 'dynamo-user', Select = 'ALL_ATTRIBUTES',
ScanFilter = {'first_name': {"AttributeValueList": [{"S": "Joe"}],
"ComparisonOperator": "EQ"}, 'last_name': {"AttributeValueList": [{"S": "Sixpack"}], "ComparisonOperator": "EQ"}})
@abhaybhargav
abhaybhargav / dynamo_loose_query.py
Last active June 28, 2018 13:06
Dynamo loose query
client.scan(TableName = 'dynamo-user', Select = 'ALL_ATTRIBUTES',
ScanFilter = {'first_name': {"AttributeValueList": [{"S": "*"}],
"ComparisonOperator": "GT"},
'last_name': {"AttributeValueList": [{"S": "*"}],
"ComparisonOperator": "GT"}})
# All results from the Database are retrieved, similar to a 1=1 SQL Injection payload
client.scan(TableName = 'dynamo-user', Select = 'ALL_ATTRIBUTES',
@abhaybhargav
abhaybhargav / kms_data_encryption.py
Created November 12, 2018 07:18
Demo of Amazon KMS => With the CMK, Envelope Encryption and Data Key
from Crypto.Cipher import AES
import boto3
from huepy import *
import os
import base64
from sys import exit
pad = lambda s: s + (32 - len(s) % 32) * ' '
plaintext_message = "Hello from we45"
client = boto3.client('kms')
@abhaybhargav
abhaybhargav / encrypt_example.tf
Created November 12, 2018 07:20
Amazon KMS Encrypt with CMK Directly - Terraform
resource "aws_kms_key" "oauth_config" {
description = "oauth config"
is_enabled = true
enable_key_rotation = true
tags {
Name = "OAuth Key"
}
}
data "aws_kms_ciphertext" "oauth" {
@abhaybhargav
abhaybhargav / key_policy_example.tf
Last active November 12, 2018 09:38
Demonstration of KMS KeyPolicy
resource "aws_kms_key" "test_key" {
description = "This is a test key that has a policy attached to it"
is_enabled = true
enable_key_rotation = true
tags {
Name = "Test Key with Policy"
}
}
data "aws_iam_policy_document" "appkeypolicy" {