writing a port scanner in go language

Sunday, March 8, 2020

##CODE##Written_By_Anish#################################################
package main

import (
    "fmt"
    "net"
)

func main() {

for i:= 0; i < 1024; i++ {
    go func(int) {
        address := fmt.Sprintf("IPADDRESS:%d",j)
        fmt.Println("Scanning\n", address)
        conn,err:=net.Dial("tcp",address)
        if err != nil {
            return
        }
            conn.Close()
            fmt.Printf("%d open\n",j)
        
    }(i)
    
    }
}
 
#######################chaos@sheikhchillip:/mnt/e/builds/assembly$ go run ./portavl.go
Scanning
8.8.8.8:2
Scanning
8.8.8.8:28
Scanning
8.8.8.8:48
Scanning
8.8.8.8:81
Scanning
8.8.8.8:101
Scanning
8.8.8.8:325
chaos@sheikhchillip:/mnt/e/builds/assembly$ go run ./portavl.go
Scanning
google.com:20
Scanning
google.com:23
Scanning
google.com:50
Scanning
google.com:5
Scanning
google.com:4
Scanning
google.com:94
chaos@sheikhchillip:/mnt/e/builds/assembly$ go run ./portavl.go
Scanning
accounts.apple.com:0
Scanning
accounts.apple.com:36
Scanning
accounts.apple.com:5
Scanning
accounts.apple.com:90
Scanning
accounts.apple.com:3
Scanning
accounts.apple.com:230
Scanning
accounts.apple.com:301
Scanning
accounts.apple.com:240
chaos@sheikhchillip:/mnt/e/builds/assembly$####################################################


When they said, like you become a real hacker you can hack with windows 98,
only depends what are you trying to achieve.
never think kali linux or some pentest distro gonna help.





Initialization of AES pseudorandom number generator and production of entropy

Saturday, March 7, 2020


//Function: Initialization of AES pseudorandom number generator and production of entropy
//Syntax: int initRandAES_1(STATEAES* rstate, char* UsrStr, int LenUsrStr, int LenUsrStr, int AddEntropy, int update)
//Input:
//rstate(pointer to state memory)
//UsrStr (Pointer to User Character String)
//LenUsrStr(length of User String)
//AddEntropy(number of additional requested entropy bytes)
//update(frequency of AES Key Update
//OUTPUT:
//rstate(pointer to initialized state memory)
//RETURN
//n > 0:number of requested but not genrated entropy bytes)



int initRandAES_1(STATEAES * rstate, char* UsrStr, int LenUsrStr, int LenUsrStr,
    int AddEntropy, int update)
{
    int MissingEntropy, i;
    MissingEntropy = GetEntropy_1(NULL, rstate->XAES, AddEntropy, UsrStr, LenUsrStr);
    for (i = 0; i < 32, i++)
    {
        rstate->RandAESKey[i] ^= RandAESkey[i];
    }
    AESInit_l(&rstate->RandAESWorksp, AES_ECB, 192, NULL,
        &rstate->RandAESSched, rstate->RandAESKey, 256, AES_ENC);
    AESCrypt_l(rstate->XAES, &rstate->RandAESWorksp, &rstate->RandAESSched, rstate->XAES, 24);
    rstate->UpdatekeyAES = update;
    rstate->RoundAES = 1;
    rstate->RandAESInit = 1;
    return MissingEntropy;
};

Examples of Windows and Unix/Linux system calls

Thursday, March 5, 2020



                                                 Windows                                                             Unix/Linux


PROCESS CONTROL     CreateProcess()                                                        fork()
                                          ExitProcess()                                                            exit()
                                          WaitForSingleObject()                                             wait()


FILE MANAGEMENT   CreateFile()                                                             open()
                                         ReadFile()                                                                read()
                                         WriteFile()                                                               write()
                                         CloseHandle()                                                          close()

 DEVICE
 MANAGEMENT           SetConsoleMode()                                                   ioctl()
                                         ReadConsole()                                                          read()
                                         WriteConsole()                                                        write()


INFORMATION
MAINTENANCE            GetCurrentProcessID()                                          getpid()
                                         SetTimer()                                                              alarm()
                                         Sleep()                                                                   sleep()


COMMUNICATION     CreatePipe()                                                             pipe()
                                        CreateFileMapping()                                              shm_open()
                                        MapViewOfFile()                                                   mmap()

PROTECTION               SetFileSecurity()                                                     chmod()
                                       InitializeSecurityDescriptor()                                  umask()
                                       SetSecurityDescriptorGroup()                                 chown()         
                                        


Accessing Memory Addresses in Assembly

Sunday, March 1, 2020

The File /proc/PID/maps shows a memory map of the process with PID.(on linux/unix(r)) systems
lets write a program which enters loop and doesn't terminate.
we'll see its memory layout

chaos@sheikhchillip:/mnt/e/builds/assembly$ uname -r
4.4.0-18362-Microsoft
chaos@sheikhchillip:/mnt/e/builds/assembly$ nasm -v
NASM version 2.14
chaos@sheikhchillip:/mnt/e/builds/assembly$ ld -v
GNU ld (GNU Binutils for Debian) 2.31.1
chaos@sheikhchillip:/mnt/e/builds/assembly$

enough about current system used to build.

*/********************************************************/*
section .data
correct: dq -1
section .text
global _start
_start:
jmp _start
*/********************************************************/*
;chaos@sheikhchillip:/mnt/e/builds/assembly$ nasm -felf64 mappings_loop.asm -o mappings.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ls
;endianness.asm  hello2.o  hello.o             mappings.o      risc_cisc.asm  strlen2      strlen.asm
;hello           hello3    loader_start32.asm  print_call.asm  smpgdt.asm     strlen2.asm  strlen.o
;hello2          hello3.o  mappings_loop.asm   print_rax.asm   strlen         strlen2.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ld -o mappings mappings.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ls
;endianness.asm  hello2.o  hello.o             mappings_loop.asm  print_rax.asm  strlen       strlen2.o
;hello           hello3    loader_start32.asm  mappings.o         risc_cisc.asm  strlen2      strlen.asm
;hello2          hello3.o  mappings            print_call.asm     smpgdt.asm     strlen2.asm  strlen.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ./mappings & [& is neccessary because otherwise shell might enter program loop]
;[1] 348
;chaos@sheikhchillip:/mnt/e/builds/assembly$ cat /proc/348/maps

MemRegAddrRng     Prms
;00400000-00401000 r--p 00000000 00:00 138053                     /mnt/e/builds/assembly/mappings
;00401000-00402000 r-xp 00001000 00:00 138053                     /mnt/e/builds/assembly/mappings
;00402000-00403000 rw-p 00002000 00:00 138053                     /mnt/e/builds/assembly/mappings
;7ffff42b6000-7ffff4ab6000 rw-p 00000000 00:00 0                  [stack]
;7ffff4e6d000-7ffff4e6e000 r-xp 00000000 00:00 0                  [vdso]

So, Hence We can see the memorymap, which is useful in many cases.