Search

How to reference Assemblies in the GAC

If you install assemblies in the GAC and then wonder why you don't see them enumerated in the Add Reference dialogs, or, if you are complaining that if you browse the assembly folder in the Windows directory, you can't see the assembly in order to add a reference to it, read on.

The Add Reference dialog box is path-based and does not enumerate the components from the GAC. The assembly folder under windows is a special folder view and so you cannot browse to an assembly from this folder and expect to be able to Add a reference to it in the normal way.

If you want to use an assembly from the GAC, you should drop your assemblies into a local folder, and then add a reference to the assembly from this folder. You may want to set the "Copy Local" property to False for that assembly if you do not want the assembly to be copied locally to your project folders. At runtime, the application will automatically use the assembly from the GAC.

How to make your custom assemblies appear in the Add Reference dialog:

To display your assembly in the Add Reference dialog box, you can add a registry key, such as the following, which points to the location of the assembly
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MyAssemblies]@="C:\\MyAssemblies" 
-- where "MyAssemblies" is the name of the folder in which the assemblies reside.


NOTE: You can create the this registry entry under the HKEY_LOCAL_MACHINE hive. This will change the setting for all of the users on the system. If you create this registry entry under HKEY_CURRENT_USER, this entry will affect the setting for only the current user.

For more information about assemblies and the GAC, vist the following MSDN Web Page: http://msdn.microsoft.com/library/en-us/cpguide/html/cpconglobalassemblycache.asp

shellcodetest.c


/*shellcodetest.c*/
char code[] = "bytecode will go here!";
int main(int argc, char **argv)
{
int (*func)();
func = (int (*)()) code;
(int)(*func)();
}

odfhex - objdump hex extractor

//**************************************
odfhex - objdump hex extractor
by steve hanna v.01
   vividmachines.com
   shanna@uiuc.edu
you are free to modify this code
but please attribute me if you
change the code. bugfixes & additions
are welcome please email me!
to compile:
g++ odfhex.cpp -o odfhex


note: the XOR option works
perfectly, but i haven't implemented
the full x86 payload decoder yet.
so that option is mostly useless.

this program extracts the hex values
from an "objdump -d <binaryname>".
after doing this, it converts the
hex into escaped hex for use in
a c/c++ program.
happy shellcoding!
***************************************/


#include <stdio.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define HEX_PER_LINE 17
char symbols[37] = "0123456789abcdefghijklmnopqrstuvwxyz";
const int MAX_BASE = 36;
int GetIndex(char * pString, char search);
int BaseToDec(char* number, int base)
{
       if( base < 2 || base > MAX_BASE)
          return 0; //Failed
       int NumLength = strlen(number);
       int PlaceValue, total = 0;

       PlaceValue = (int)pow(base,NumLength-1);


      for(int i=0;i<numlength br="" i="">      {
          total += GetIndex(symbols,*number)*PlaceValue;
          number++;
          PlaceValue /= base; //Next digit's place value (previous/base)
      }
     return total;
}

int GetIndex(char * pString, char search)
{
     int index = 0;
     while(*pString != '0')
     {
       if(*pString==search)
               break;
       pString++;
       index++;
     }
     return index;
}


int main(int argc, char** argv)
{
       FILE* dump = NULL;
       long length = 0;
       char* content;
       int i=0;
       int count =0;
       int total=0;
       int XORvalue=0;
       bool XORit = false;
       char HexNumber[3]={'\0'};

       printf("\nOdfhex - object dump shellcode extractor - by steve hanna - v.01\n");

       if(argc < 2)
       {

             printf("%s: <object dump="" file=""> [-x xor offset in decimal] \n",argv[0]);
             return -1;
       }

       dump = fopen(argv[1],"r");
       if(!dump)
       {
              printf("Error: Couldn't open file.\n");
              return -1;
       }

       fseek(dump,0,SEEK_END);

       length = ftell(dump);

       content = new char[length+1];
       memset(content,0,sizeof(content));
       printf("Trying to extract the hex of %s which is %d bytes long\n",argv[1],length);

       if (argc > 3 &&  !strcmp(argv[2],"-x"))
       {
              XORit =true;
              XORvalue = BaseToDec(argv[3],16);
              printf("XORing with 0x%02x\n",XORvalue);
       }
       fseek(dump,0,SEEK_SET);
       for(int i=0; i < length; i++)
       {
              content[i] = fgetc(dump);
       }
       fclose(dump);

       while(count !=4)
       {

              if(content[i] == ':')
                     count++;
              i++;
       }
       count = 0;
		
	   printf("\"");
       while(i < length)
       {
			if( (content[i-1] == ' ' || content[i-1]=='\t') &&
                (content[i+2] == ' ' ) &&
                (content[i] != ' ') &&
                (content[i+1] != ' ') &&
                ((content[i]>='0' && content[i]<='9') || (content[i]>='a' && content[i]<='f')) &&
                ((content[i+1]>='0' && content[i+1]<='9') || (content[i+1]>='a' && content[i+1]<='f'))
              )
				{
					if(XORit)
					{
				        HexNumber[0] = content[i];
				        HexNumber[1] = content[i+1];

					    printf("\\x%02x",BaseToDec(HexNumber,16) ^ XORvalue);
					}
					else
						printf("\\x%c%c",content[i],content[i+1]);

                     count++;
                     total++;   
            }
		 
			if(i+1 == length)
			{
				 printf("\";\n");
			}
			else if(count == HEX_PER_LINE) 
			{
				printf("\"\\\n\"");
				count =0;
			}
       i++;
       }
	   
       delete[] content;
       printf("\n%d bytes extracted.\n\n",total);
       return 0;
}