Category Archives: Programming

Loading
loading..

The page is up for my newest book “Penetration Testing With Perl” !!

I just finished Chapter 7 (SQL Injection with Perl) which was a very long chapter. There will be 13 so far, so I am closer to finishing than I was during my last post about it. It’s an amazing experience, in which I learn, get frustrated, get excited and happy, and feel the absolute power of Perl at my fingertips all at the same time. This is definitley my life’s biggest work to date.

They have the amazon page up too, and the book will also be available on O’Reilly too. It is kinda expensive, but considering the content, well worth it. I take the reader deep into information security using ONLY Perl, including libpcap with WiFi, cracking WPA2 passwords, web application testinig with custom algorithms and mathematics to back them up, etc. I even teach a vast majority of the most important content from the Regular Expression book I recently published as well, with Linux OS stuff. Basically everything I have learned over the last 13 years, along with any piece of code, including WEAKERTH4N LINUX is documented as a “how to” in this text book.

~Douglas

Rather than write a “free” article for an online magazine, I figured I’d just put this right here on my site. It’s a simple proposal for credential analysis from leaked credentials and from those gleaned during a penetration test for more accurate, targeted credential attack vectors. I propose not only simple methodology practices as examples, but even terminologies for the practice as well.

Hope you enjoy,
~Douglas

Linkage and Automatic Variables

There are two different kinds of linkage for C variables; internal and external. And, of course, can also have variables with no linkage at all. But, what is linkage? Well linkage refers to the life span and scope of the variable. When we went over for() loops in tutorial 7, we were using an automatic variable i. i only lived within the for() loop and the scope only allowed i to be accessed inside the block, or compound statement of it’s parent for() loop. This is an automatic variable and we say that it has no linkage at all. In fact, we can use the auto storage class specifier like so:

#include<stdio.h>
int main(void){
  auto int i;
  for(i=0;i<3;i++)
    printf("%d\n",i);
  return 0;
}

The integer i would then be freed when the main() function exits.

Static Variables

How could we make i live throughout the application? Well, we define a new storage class, static. The static storage class retains variables throughout the duration of the program’s execution. Let’s take a look at a quick example:

int inc(void){
  static int i = 0;
  i++;
  return i;
}

The above code defines a static variable i which has no linkage. It can only be accessed via the inc() function, but lives throughout the application’s execution time. It looks like we define i each time we call the function inc(), but the C code actually recognizes that this variable is static after initially defining it. So it simply refers to it’s memory space with each consecutive call to inc() rather than redefining it as we see in our full code example below.

#include<stdio.h>
int main(void){
  inc();
  inc();
  inc();
  return 0;
}
int inc(void){
  static int i = 0;
  i++;
  printf(“%d\n”,i);
}

The code above, when compiled and ran, returns the result:

1
2
3

And as we see, we didn’t “redefine” the integer i. We may have also noticed that the inc() function is supposed to return an integer according to it’s definition. This is true because the creation and modification of i is returning an integer! The variable i has static storage duration, no linkage and only block scope. Block scope, again, simply means that the variable can only be accessed by the block in which it was created.

No Linkage

Automatic variables that are thrown away at the end of a function or block of code, such as i in the for() loop, have absolutely no linkage. They don’t live throughout the duration of execution, so they cannot be accessed just anywhere within the application- just the block which creates them.

Internal Linkage

Static variables with internal linkage can be thought of as a global variable that can only be accessed by the file in which it was created. Now, up to this point, we have only created single file C programs. C programs can be comprised of multiple files and linkage can occur throughout, as external linkage.

#include
static int i = 0;
int main(void){
  extern int i;
  printf(“5d\n”,i);
  return 0;
}

The code above set the integer i to be static, outside of any function. This defines the variable with Internal Linkage. It is global to the file in which it lives, but only to that file.

External Linkage

Static variables with external linkage can be thought of as a global variable which can be accessed anywhere from any file in our C program. Below, is the simplest form of a static variable with external linkage.

#include
int i = 0;
int main(void){
  extern int i;
  printf(“5d\n”,i);
  return 0;
}

The integer i is an external variable of the external storage class that was defined outside of any function. It can be used by any file within our C program. We have re-declared (this process is optional according to most documentations on the subject), i using the external storage class specifier. This is a good example to use when trying to understand the difference of defining and declaring a variable. The extern specifier for int i is declaring that we want to use the i integer defined elsewhere. The first int i = 0; line is a declaration AND definition as we tell the compiler to set aside memory for it and place in the integer value 0.

Storage Classes in C

Now that we have covered different linkage, storage classes and examples of each, let’s take a look at four storage classes and summarize what we have learned above.

1. auto - automatic storage duration variables, thrown away at the end of the block in which they are created.
  auto int i = 0;
2. register - stored in either the CPU registers, or the fastest storage available. These are also of automatic storage duration.
  register int i = 0;
3. static - static storage duration makes a variable live throughout the execution of our program.
These are defined outside of any function and can have the static specifier omitted.
  static int i = 0;
4. extern - external storage class, external variable which also has static storage duration. These are defined and declared outside of any function.
  extern int i = 0;

Static and External Functions

Functions can also have static or external storage classes. A static function prototyped and defined as,
static int func(void);
Can be accessed anywhere within the file in which it was defined. We can have external functions like so,
extern int func(void);
which can be accessed by any file within our C program. Let’s take a look at a simple static function. To define a static function, it must be prototyped before main().

#include<stdio.h>
static void callIt(register int i);
int main(void){
  callIt(100);
  return 0;
}
static void callIt(register int i){
  printf(“%d,\n”,i);
}

This entire tutorial should offer help in understanding different storage classes, duration types, defining and declaring, and linkage.

)

Almost complete. WARCARRIER for Android Tablets.



This is the main screen at startup, including the menu options.

Click on “catchMeNG! in the settings bar at the top right and you can input a string to troll for. This includes Bluetooth devices, BSSIDs, ESSIDs, etc.

You can also choose “Plot Waypoint” to plot a new way point onto the Google Map:

If you long-press on a any field (as the “Help” dialog shows from the Settings menu) You can find more information on the specific data that is presented.

And as of 1.1 Beta, you can plot and scan for Bluetooth devices:

This will make my life so much easier as I only have to write this Java code to run on one specific hardware type. Anything that goes wring is the SDKs fault, or the manufacturer for not using standard or compliant hardware (e.g. for radios).

Time to catch up on some R&R
~Douglas

Layout mode
Predefined Skins
Custom Colors
Choose your skin color
Patterns Background
Images Background