/*
 *
 *                                  Juggernaut
 *                                  Version 1.2
 *
 *                            1996/7 Guild productions
 *                           daemon9[guild|phrack|r00t]
 *
 *                         comments to route@infonexus.com
 *
 *  This coding project made possible by a grant from the Guild corporation
 *
 *  menu.c - menu functions.
 * 
 */

#include <stdio.h>

extern char version[];

/*
 *  Initial Screen
 */

void minit(){
 
    printf("\t\t\t   J U G G E R N A U T\n");
    printf("\t\t    multipurpose network tool for Linux\n");
    printf("\t\t\t       version: %s\n",version);
    printf("\n\n\n\n\n\n");
    printf("\t  (c) 1996/7 daemon9 | A Guild Corporation Production\t\t\t\n");
    printf("\n\n\n\n\n\n");
}

/*
 *  Main Menu
 */

void mmain(){

    printf("\t\t\t           Juggernaut\n");
    printf("\t\t\t+------------------------------+\n");
    printf("\t\t\t?) Help\n");
    printf("\t\t\t0) Program information\n");
    printf("\t\t\t1) Connection database\n");
    printf("\t\t\t2) Spy on a connection\n");
    printf("\t\t\t3) Reset a connection\n");
    printf("\t\t\t4) Automated connection reset daemon\n");
    printf("\t\t\t5) Simplex connection hijack\n");
    printf("\t\t\t6) Interactive connection hijack\n");
    printf("\t\t\t7) Packet assembly module\n");
    printf("\t\t\t8) Souper sekret option number eight\n");
    printf("\t\t\t9) Step Down\n");
    printf("\n\n\n\n\n\n\n\n\n");
    printf(">");
}	

/*
 *  Packet Assembly Menu [prometheus module]
 */

void mpkta(){

    printf("\t\t\t     Packet Assembly Module (beta)\n");
    printf("\t\t\t+------------------------------+\n");
    printf("\t\t\t1. TCP Assembler\n");
    printf("\t\t\t2. UDP Assembler\n");
    printf("\t\t\t3. ICMP Assembler\n");
    printf("\t\t\t4. IP Assembler\n");
    printf("\t\t\t5. Return to previous menu\n");
    printf("\n\n\n\n\n\n\n\n\n\n");
    printf(">");
}

/*
 *  TCP assembly options menu
 */

void mpktatcp(packetready,source,destination,seqnum,acknum,control,window,data)
int packetready;
unsigned short source;
unsigned short destination;
unsigned long seqnum;
unsigned long acknum;
char *control;
unsigned short window;
char data[512];
{

    printf("\t\t\t     TCP Packet Assembly\n");
    printf("\t\t\t+------------------------------+\n");
    if(!(packetready&0x01))printf("\t\t\t1. Source port\n");
    else printf("\t\t\tSource port: %d\n",source);
    if(!(packetready&0x02))printf("\t\t\t2. Destination port\n");
    else printf("\t\t\tDestination port: %d\n",destination);
    if(!(packetready&0x04))printf("\t\t\t3. Sequence Number\n");
    else printf("\t\t\tSequence Number: %ld\n",seqnum);
    if(!(packetready&0x08))printf("\t\t\t4. Acknowledgement Number\n");
    else printf("\t\t\tAcknowledgement Number: %ld\n",acknum);
    if(!(packetready&0x10))printf("\t\t\t5. Control Bits\n");
    else printf("\t\t\tControl Flags: %s\n",control);
    if(!(packetready&0x20))printf("\t\t\t6. Window Size\n");
    else printf("\t\t\tWindow Size: %d\n",window);
    if(!(packetready&0x40))printf("\t\t\t7. Data Payload\n");
    else printf("\t\t\tData payload: %s\n",data);
    printf("\t\t\t8. Return to previous menu\n");
    printf("\t\t\t9. Return to main menu\n");
    if(packetready==0x7F)printf("\t\t\t10. Pass packet to RIP assembler\n");
    printf("\n\n\n\n\n\n\n\n\n\n");
    printf(">");
}

/*
 *  UDP assembly options menu
 */

void mpktaudp(packetready,source,destination,data)
int packetready;
unsigned short source;
unsigned short destination;
char data[512];
{
    printf("\t\t\t     UDP Packet Assembly\n");
    printf("\t\t\t+------------------------------+\n");
    if(!(packetready&0x01))printf("\t\t\t1. Source port\n");
    else printf("\t\t\tSource port: %d\n",source);
    if(!(packetready&0x02))printf("\t\t\t2. Destination port\n");
    else printf("\t\t\tDestination port: %d\n",destination);
    if(!(packetready&0x04))printf("\t\t\t3. Data payload\n");
    else printf("\t\t\tData payload: %s\n",data);
    printf("\t\t\t4. Return to previous menu\n");
    printf("\t\t\t5. Return to main menu\n");
    if(packetready==0x7)printf("\t\t\t6. Pass packet to RIP assembler\n");
    printf("\n\n\n\n\n\n\n\n\n\n");
    printf(">");
}

/*
 *  ICMP assembly options menu
 */

void mpktaicmp(packetready,type,code,data)
int packetready;
unsigned short type;
unsigned short code;
char data[512];
{

    printf("\t\t\t     ICMP Packet Assembly\n");
    printf("\t\t\t+------------------------------+\n");
    if(!(packetready&0x01))printf("\t\t\t1. Type\n");
    else printf("\t\t\tType: %d\n",type);
    if(!(packetready&0x02))printf("\t\t\t2. Code\n");
    else printf("\t\t\tCode: %d\n",code);
    if(!(packetready&0x04))printf("\t\t\t3. Data payload\n");
    else printf("\t\t\tData payload: %s\n",data);
    printf("\t\t\t4. Return to previous menu\n");
    printf("\t\t\t5. Return to main menu\n");
    if(packetready==0x07)printf("\t\t\t6. Pass packet to RIP assembler\n");
    printf("\n\n\n\n\n\n\n\n\n\n");
    printf(">");
}

/*
 *  IP assembly options menu
 */

void mpktaip(packetready,tos,fflags,fo,ttl,saddr,daddr,number,packettype)
int packetready;
char *tos;
char *fflags;
unsigned short fo;
unsigned short ttl;
char *saddr;
char *daddr;
int number;
char *packettype;
{

    printf("\t\t\t     IP Packet Assembly\n");
    printf("\t\t\t+------------------------------+\n");
    if(!(packetready&0x01))printf("\t\t\t1. TOS\n");
    else printf("\t\t\tTOS: %s\n",tos);
    if(!(packetready&0x02))printf("\t\t\t2. Fragment Flags\n");
    else printf("\t\t\tFragment flags: %s\n",fflags);
    if(!(packetready&0x04))printf("\t\t\t3. Fragment Offset\n");
    else printf("\t\t\tFragment offset: %d\n",(fo&0x1fff));
    if(!(packetready&0x08))printf("\t\t\t4. TTL\n");
    else printf("\t\t\tTTL: %d\n",ttl);
    if(!(packetready&0x10))printf("\t\t\t5. Source Address\n");
    else printf("\t\t\tSource Address: %s\n",saddr);
    if(!(packetready&0x20))printf("\t\t\t6. Destination Address\n");
    else printf("\t\t\tDestination Address: %s\n",daddr);
    if(!(packetready&0x40))printf("\t\t\t7. Number of packets to send\n");
    else printf("\t\t\tSending %d packet(s)\n",number);
    printf("\t\t\t8. Return to previous menu\n");
    printf("\t\t\t9. Return to main menu\n");
    if(packetready==0x7f)printf("\t\t\t10. Transmit %s packet(s)\n",packettype);
    printf("\n\n\n\n\n\n\n\n\n\n");
    printf(">");
}

/*
 *  Clear the Screen
 */

void mwipe(){

    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}
