npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zuln

v1.0.5

Published

Zuln is an AI-powered vulnerability hunter designed to assist in identifying security vulnerabilities in code. It leverages AI completion and Language Model Learning (LLM) techniques to analyze code and extract patterns indicative of vulnerabilities. This

Downloads

6

Readme

Zuln - AI Vulnerability Hunter

Zuln is an AI-powered vulnerability hunter designed to assist in identifying security vulnerabilities in code. It leverages AI completion and Language Model Learning (LLM) techniques to analyze code and extract patterns indicative of vulnerabilities. This README provides installation instructions and demonstrates how to use Zuln for sniffing out specific types of vulnerabilities.

Installation

To install Zuln, execute the following command:

npm install -g zuln

Sniffing

Zuln's sniffing feature allows you to extract main patterns of vulnerable code using AI completion and LLM. It currently supports detecting vulnerabilities related to cryptographic issues and out-of-bounds errors. The following examples demonstrate how to use Zuln to identify these vulnerabilities.

Cryptographic Vulnerability

To detect cryptographic vulnerabilities, use the provided crypto-yafm.py script. Below is an example of how to use Zuln for this purpose:

zuln snif ./crypto-yafm.py
#!/usr/bin/python3 -u
#Copyright 2020 Google LLC
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#    https://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import random
from Crypto.Util.number import *
from Crypto.Cipher import PKCS1_OAEP
from Crypto.PublicKey import RSA
import binascii

def generate_prime(prime_len):
  bits_len = 180
  while True:
    bits = random.getrandbits(bits_len)
    idxs = random.sample(list(range(1, prime_len-2)), bits_len)
    p = 1 | 2**(prime_len - 1) | 2**(prime_len - 2)
    for i in range(bits_len):
      p += (bits >> i & 1)*2**idxs[i]
    if isPrime(p):
      return p

key = None
flag = open("flag.txt", "rb").read()

print("Welcome to my Prime Obsession. Tell me what do you want.\n")
while True:
    print("[1] Generate key")
    print("[2] Get Encrypted flag")
    print("[3] Exit")
    opt = int(input(">>> "))
    if opt == 1:
        p = generate_prime(1024)
        q = generate_prime(1024)
        e = 65537
        n = p*q
        key = RSA.construct((n, e))
        print(key.exportKey('PEM').decode())
    if opt == 2:
        if not key:
            print("No key generated :/")
        else:
            cipher = PKCS1_OAEP.new(key)
            print(binascii.hexlify(cipher.encrypt(flag)).decode())
    if opt == 3:
        print("You are not obsessed enough :/")
        break
    print("\n")

Crypto Vulnerability Result

The output image demonstrates the vulnerable parts of the code and highlights potential security concerns.

Out-of-Bounds Vulnerability

Zuln can also help identify out-of-bounds vulnerabilities. Use the provided damnvuln.c file to detect such issues. Here's an example command:

zuln snif ./damnvuln.c
//https://github.com/hardik05/Damn_Vulnerable_C_Program/blob/master/imgRead.c

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Image
{
        char header[4];
        int width;
        int height;
        char data[10];
};

int ProcessImage(char* filename){

        FILE *fp;
        char ch;
        struct Image img;

        fp = fopen(filename,"r"); 

        if(fp == NULL)
        {
                printf("\nCan't open file or file doesn't exist.");
                exit(0);
        }

        printf("\n\tHeader\twidth\theight\tdata\t\r\n");

        while(fread(&img,sizeof(img),1,fp)>0){
                printf("\n\t%s\t%d\t%d\t%s\r\n",img.header,img.width,img.height,img.data);

                int size1 = img.width + img.height; //Vulnerability: integer overflow
                char* buff1=(char*)malloc(size1);

                memcpy(buff1,img.data,sizeof(img.data)); //Vulnerability: no data buffer size/malloc success check?
                free(buff1);

                if (size1/2==0){
                        free(buff1); //Vulnerability: double free
                }
                else{
                        if(size1 == 123456){
                                buff1[0]='a'; //Vulnerability: use after free
                        }
                }

                int size2 = img.width - img.height+100; //Vulnerability: integer underflow
                //printf("Size1:%d",size1);
                char* buff2=(char*)malloc(size2);

                memcpy(buff2,img.data,sizeof(img.data));

                int size3= img.width/img.height;
                //printf("Size2:%d",size3);

                char buff3[10];
                char* buff4 =(char*)malloc(size3);
                memcpy(buff4,img.data,sizeof(img.data));

                char OOBR_stack = buff3[size3+100]; //Vulnerability: out of bound read (stack)
                char OOBR_heap = buff4[100];

                buff3[size3+100]='c'; //Vulnerability: out of bound write (Stack)
                buff4[100]='c'; //Vulnerability: out of bound write (Heap)

                if(size3>10){
                                buff4=0; //memory leak?
                }
                else{
                        free(buff4);
                }

                free(buff2);
        }
        fclose(fp);
}

int main(int argc,char **argv)
{
        ProcessImage(argv[1]);
}

Out-of-Bounds Vulnerability Explanation 1

Out-of-Bounds Vulnerability Explanation 2

The images illustrate the identified vulnerabilities and provide explanations for each vulnerability discovered.

Feel free to leverage Zuln for vulnerability hunting and secure your code effectively!

Contributing

Contributions to Zuln are welcome! If you discover any issues or have suggestions for improvements, please submit an issue or a pull request.