]> git.sesse.net Git - freerainbowtables/commitdiff
actually commit everything
authorJames Nobis <quel@paranoia.quelrod.net>
Sat, 9 Oct 2010 20:47:51 +0000 (15:47 -0500)
committerJames Nobis <quel@paranoia.quelrod.net>
Sat, 9 Oct 2010 20:47:51 +0000 (15:47 -0500)
Client Applications/converti2/Makefile [new file with mode: 0644]
Client Applications/converti2/Public.cpp
Client Applications/converti2/Public.h
Client Applications/converti2/converti2.cpp
Client Applications/converti2/makefile [deleted file]

diff --git a/Client Applications/converti2/Makefile b/Client Applications/converti2/Makefile
new file mode 100644 (file)
index 0000000..d3715df
--- /dev/null
@@ -0,0 +1,26 @@
+SHELL = /bin/sh
+CC = g++
+OPTIMIZATION = -O3
+INCLUDES = -I../../Common/rt\ api
+# XXX todo currently only 32-bit targets work
+CFLAGS = -Wall -m32 -ansi $(INCLUDES) $(OPTIMIZATION) -c
+LFLAGS = -Wall -m32 -ansi $(INCLUDES) $(OPTIMIZATION)
+LIBS = 
+OBJS = MemoryPool.o Public.o
+COMMON_API_PATH = ../../Common/rt\ api
+
+all: converti2
+
+converti2: $(OBJS)
+       $(CC) $(LFLAGS) $(OBJS) $(LIBS) converti2.cpp -o converti2
+
+clean:
+       rm -f *.o converti2
+
+rebuild: clean all
+
+MemoryPool.o: $(COMMON_API_PATH)/MemoryPool.h $(COMMON_API_PATH)/MemoryPool.cpp Public.h
+       $(CC) $(CFLAGS) $(COMMON_API_PATH)/MemoryPool.cpp
+
+Public.o: Public.h Public.cpp
+       $(CC) $(CFLAGS) Public.cpp
index e279c56a349a0c9b0ae61e4bf7f039115dc1f6ab..7e5420366852e2dd76ecabfd63496eaffacd3b09 100644 (file)
@@ -1,7 +1,26 @@
 /*
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * This file is part of freerainbowtables.
+ *
+ * freerainbowtables is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * freerainbowtables is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with freerainbowtables.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifdef _WIN32
 */
 
 #ifdef _WIN32
 
 #ifdef _WIN32
        #include <windows.h>
 
 #ifdef _WIN32
        #include <windows.h>
-#else
-       #include <sys/sysinfo.h>
+#elif defined(__APPLE__) || \
+       ((defined(__unix__) || defined(unix)) && !defined(USG))
+
+       #include <sys/param.h>
+
+       #if defined(BSD)
+               #include <sys/sysctl.h>
+       #elif defined(__linux__)
+               #include <sys/sysinfo.h>
+       #else
+               #error Unsupported Operating system
+       #endif
 #endif
 
 //////////////////////////////////////////////////////////////////////
 #endif
 
 //////////////////////////////////////////////////////////////////////
@@ -66,12 +95,13 @@ bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset)
        // Example: hybrid(mixalpha-numeric-all-space#1-6,numeric#1-4)
        if(sCharset.substr(0, 6) != "hybrid") // Not hybrid charset
                return false;
        // Example: hybrid(mixalpha-numeric-all-space#1-6,numeric#1-4)
        if(sCharset.substr(0, 6) != "hybrid") // Not hybrid charset
                return false;
-       size_t nEnd = sCharset.rfind(')');
-       size_t nStart = sCharset.rfind('(');
+
+       UINT4 nEnd = (int) sCharset.rfind(')');
+       UINT4 nStart = (int) sCharset.rfind('(');
        string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1);
        vector<string> vParts;
        SeperateString(sChar, ",", vParts);
        string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1);
        vector<string> vParts;
        SeperateString(sChar, ",", vParts);
-       for(int i = 0; i < vParts.size(); i++)
+       for(UINT4 i = 0; i < vParts.size(); i++)
        {
                tCharset stCharset;
                vector<string> vParts2;
        {
                tCharset stCharset;
                vector<string> vParts2;
@@ -97,7 +127,7 @@ bool ReadLinesFromFile(string sPathName, vector<string>& vLine)
                data[len] = '\0';
                string content = data;
                content += "\n";
                data[len] = '\0';
                string content = data;
                content += "\n";
-               delete data;
+               delete [] data;
 
                unsigned int i;
                for (i = 0; i < content.size(); i++)
 
                unsigned int i;
                for (i = 0; i < content.size(); i++)
@@ -185,22 +215,33 @@ string HexToStr(const unsigned char* pData, int nLen)
        return sRet;
 }
 
        return sRet;
 }
 
-unsigned int GetAvailPhysMemorySize()
+uint64 GetAvailPhysMemorySize()
 {
 #ifdef _WIN32
 {
 #ifdef _WIN32
-               MEMORYSTATUS ms;
-               GlobalMemoryStatus(&ms);
-               return ms.dwAvailPhys;
-#else
+       MEMORYSTATUS ms;
+       GlobalMemoryStatus(&ms);
+       return ms.dwAvailPhys;
+#elif defined(BSD)
+       int mib[2] = { CTL_HW, HW_PHYSMEM };
+       uint64 physMem;
+       //XXX warning size_t isn't portable
+       size_t len;
+       len = sizeof(physMem);
+       sysctl(mib, 2, &physMem, &len, NULL, 0);
+       return physMem;
+#elif defined(__linux__)
        struct sysinfo info;
        struct sysinfo info;
-       sysinfo(&info);                 // This function is Linux-specific
-       return info.freeram;
+       sysinfo(&info);
+       return ( info.freeram + info.bufferram ) * (unsigned long) info.mem_unit;
+#else
+       return 0;
+       #error Unsupported Operating System
 #endif
 }
 
 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen)
 {
 #endif
 }
 
 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen)
 {
-       int i;
+       UINT4 i;
        for (i = 0; i < sHash.size() / 2; i++)
        {
                string sSub = sHash.substr(i * 2, 2);
        for (i = 0; i < sHash.size() / 2; i++)
        {
                string sSub = sHash.substr(i * 2, 2);
@@ -220,3 +261,59 @@ void Logo()
        printf("original code by Zhu Shuanglei <shuanglei@hotmail.com>\n");
        printf("http://www.antsight.com/zsl/rainbowcrack/\n\n");
 }
        printf("original code by Zhu Shuanglei <shuanglei@hotmail.com>\n");
        printf("http://www.antsight.com/zsl/rainbowcrack/\n\n");
 }
+
+// XXX nmap is GPL2, will check newer releases regarding license
+// Code comes from nmap, used for the linux implementation of kbhit()
+#ifndef _WIN32
+
+static int tty_fd = 0;
+struct termios saved_ti;
+
+int tty_getchar()
+{
+       int c, numChars;
+
+       if (tty_fd && tcgetpgrp(tty_fd) == getpid()) {
+               c = 0;
+               numChars = read(tty_fd, &c, 1);
+               if (numChars > 0) return c;
+       }
+
+       return -1;
+}
+
+void tty_done()
+{
+       if (!tty_fd) return;
+
+       tcsetattr(tty_fd, TCSANOW, &saved_ti);
+
+       close(tty_fd);
+       tty_fd = 0;
+}
+
+void tty_init()
+{
+       struct termios ti;
+
+       if (tty_fd)
+               return;
+
+       if ((tty_fd = open("/dev/tty", O_RDONLY | O_NONBLOCK)) < 0) return;
+
+       tcgetattr(tty_fd, &ti);
+       saved_ti = ti;
+       ti.c_lflag &= ~(ICANON | ECHO);
+       ti.c_cc[VMIN] = 1;
+       ti.c_cc[VTIME] = 0;
+       tcsetattr(tty_fd, TCSANOW, &ti);
+
+       atexit(tty_done);
+}
+
+void tty_flush(void)
+{
+       tcflush(tty_fd, TCIFLUSH);
+}
+// end nmap code
+#endif
index a2f5657fcb5d485e3a7f0994fb2726560dc31554..6c15430388ee3fa4c8f2e9ee0cf956463c663011 100644 (file)
@@ -1,8 +1,26 @@
 /*
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * This file is part of freerainbowtables.
+ *
+ * freerainbowtables is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * freerainbowtables is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with freerainbowtables.  If not, see <http://www.gnu.org/licenses/>.
+ */
 
 #ifndef _PUBLIC_H
 #define _PUBLIC_H
 
 #ifndef _PUBLIC_H
 #define _PUBLIC_H
 #include <string>
 #include <vector>
 #include <list>
 #include <string>
 #include <vector>
 #include <list>
-using namespace std;
 
 
-#ifdef _WIN32
-       #define uint64 unsigned __int64
-#else
-       #define uint64 u_int64_t
-#endif
+#include "global.h"
+
+using namespace std;
 
 struct RainbowChain
 {
 
 struct RainbowChain
 {
@@ -68,6 +83,21 @@ typedef struct
 #define MAX_HASH_LEN  256
 #define MAX_SALT_LEN  256
 
 #define MAX_HASH_LEN  256
 #define MAX_SALT_LEN  256
 
+// XXX nmap is GPL2, will check newer releases regarding license
+// Code comes from nmap, used for the linux implementation of kbhit()
+#ifndef _WIN32
+#include <unistd.h>
+#include <termios.h>
+#include <fcntl.h>
+
+int tty_getchar();
+void tty_done();
+void tty_init();
+void tty_flush(void);
+// end nmap code
+
+#endif
+
 unsigned int GetFileLen(FILE* file);
 string TrimString(string s);
 bool ReadLinesFromFile(string sPathName, vector<string>& vLine);
 unsigned int GetFileLen(FILE* file);
 string TrimString(string s);
 bool ReadLinesFromFile(string sPathName, vector<string>& vLine);
@@ -75,7 +105,7 @@ bool SeperateString(string s, string sSeperator, vector<string>& vPart);
 string uint64tostr(uint64 n);
 string uint64tohexstr(uint64 n);
 string HexToStr(const unsigned char* pData, int nLen);
 string uint64tostr(uint64 n);
 string uint64tohexstr(uint64 n);
 string HexToStr(const unsigned char* pData, int nLen);
-unsigned int GetAvailPhysMemorySize();
+uint64 GetAvailPhysMemorySize();
 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen);
 bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset);
 void Logo();
 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen);
 bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset);
 void Logo();
index a73fd95ed05a0bbb52139f6ba01ce1c9f1ffdbac..db703e92d243a16dd46cbd0fa6475758f49fc0c9 100644 (file)
@@ -1,19 +1,23 @@
 #include <string>
 #include <vector>
 #ifdef _WIN32
 #include <string>
 #include <vector>
 #ifdef _WIN32
-#include <io.h>
+       #include <io.h>
+       #include <conio.h>
 #else
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <unistd.h>
 #endif
 
 #else
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <unistd.h>
 #endif
 
+#include <stdlib.h>
+#include <string.h>
 #include <time.h>
 #include <math.h>
 #include <vector>
 #include <time.h>
 #include <math.h>
 #include <vector>
-#include <conio.h>
+
 #include "Public.h"
 #include "MemoryPool.h"
 #include "Public.h"
 #include "MemoryPool.h"
+
 using namespace std;
 
 void Usage()
 using namespace std;
 
 void Usage()
@@ -300,8 +304,8 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
        if (file != NULL && fileR != NULL)
        {
                // File length check
        if (file != NULL && fileR != NULL)
        {
                // File length check
-               unsigned int nFileLen = GetFileLen(file);
-               unsigned int nTotalChainCount = 0;
+               UINT4 nFileLen = GetFileLen(file);
+               UINT4 nTotalChainCount = 0;
                if(hascp == 0) nTotalChainCount = nFileLen / 16;
                else nTotalChainCount = nFileLen / 18;
                if ((hascp == 0 && nFileLen % 16 != 0) || (hascp == 1 && nFileLen % 18 != 0))
                if(hascp == 0) nTotalChainCount = nFileLen / 16;
                else nTotalChainCount = nFileLen / 18;
                if ((hascp == 0 && nFileLen % 16 != 0) || (hascp == 1 && nFileLen % 18 != 0))
@@ -324,12 +328,12 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
                                fseek(file, 0, SEEK_SET);
                                uint64 curPrefix = 0, prefixStart = 0;
                                vector<IndexRow> indexes;
                                fseek(file, 0, SEEK_SET);
                                uint64 curPrefix = 0, prefixStart = 0;
                                vector<IndexRow> indexes;
-                               int nRainbowChainCountRead = 0;
+                               UINT4 nRainbowChainCountRead = 0;
                                while (true)    // Chunk read loop
                                {
 /*                                     if (ftell(file) == nFileLen)
                                                break;*/
                                while (true)    // Chunk read loop
                                {
 /*                                     if (ftell(file) == nFileLen)
                                                break;*/
-                                       int nReadThisRound;
+                                       UINT4 nReadThisRound;
                                        memset(pChain, 0x00, nAllocatedSize);
                                        printf("reading...\n");
                                        clock_t t1 = clock();
                                        memset(pChain, 0x00, nAllocatedSize);
                                        printf("reading...\n");
                                        clock_t t1 = clock();
@@ -355,7 +359,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
                                        printf("%u bytes read, disk access time: %.2f s\n", nDataRead , fTime);
                                        t1 = clock();
 
                                        printf("%u bytes read, disk access time: %.2f s\n", nDataRead , fTime);
                                        t1 = clock();
 
-                                       for(int i = 0; i < nReadThisRound; i++)
+                                       for(UINT4 i = 0; i < nReadThisRound; i++)
                                        {
                                                if(showDistribution == 1)
                                                {
                                        {
                                                if(showDistribution == 1)
                                                {
@@ -418,7 +422,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
                                indexes.push_back(index);
 
                                IndexRow high = {0}; // Used to find the highest numbers. This tells us how much we can pack the index bits
                                indexes.push_back(index);
 
                                IndexRow high = {0}; // Used to find the highest numbers. This tells us how much we can pack the index bits
-                               for(int i = 0; i < indexes.size(); i++)
+                               for(UINT4 i = 0; i < indexes.size(); i++)
                                {
                                        if(indexes[i].numchains > high.numchains)
                                                high.numchains = indexes[i].numchains;
                                {
                                        if(indexes[i].numchains > high.numchains)
                                                high.numchains = indexes[i].numchains;
@@ -441,7 +445,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
                                fwrite(&rti_cplength, 1, 1, pFileIndex);
 //                                     fwrite(&m_rti_index_indexlength , 1, 1, pFileIndex);
                                fwrite(&m_rti_index_numchainslength, 1, 1, pFileIndex);
                                fwrite(&rti_cplength, 1, 1, pFileIndex);
 //                                     fwrite(&m_rti_index_indexlength , 1, 1, pFileIndex);
                                fwrite(&m_rti_index_numchainslength, 1, 1, pFileIndex);
-                               for(int i = 0; i < rti_cppos.size(); i++)
+                               for(UINT4 i = 0; i < rti_cppos.size(); i++)
                                {
                                        fwrite(&rti_cppos[i], 1, 4, pFileIndex); // The position of the checkpoints
                                }
                                {
                                        fwrite(&rti_cppos[i], 1, 4, pFileIndex); // The position of the checkpoints
                                }
@@ -449,11 +453,10 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
                                int zero = 0;
                                fwrite(&indexes[0].prefix, 1, 8, pFileIndex); // Write the first prefix
                                unsigned int lastPrefix = 0;
                                int zero = 0;
                                fwrite(&indexes[0].prefix, 1, 8, pFileIndex); // Write the first prefix
                                unsigned int lastPrefix = 0;
-                               for(int i = 0; i < indexes.size(); i++)
+                               for(UINT4 i = 0; i < indexes.size(); i++)
                                {
                                        if(i == 0)
                                                lastPrefix = indexes[0].prefix;
                                {
                                        if(i == 0)
                                                lastPrefix = indexes[0].prefix;
-                                       unsigned int indexrow = 0;
                                        // Checks how big a distance there is between the current and the next prefix. eg cur is 3 and next is 10 = 7.
                                        unsigned int diffSize = indexes[i].prefix - lastPrefix; 
                                        if(i > 0 && diffSize > 1)
                                        // Checks how big a distance there is between the current and the next prefix. eg cur is 3 and next is 10 = 7.
                                        unsigned int diffSize = indexes[i].prefix - lastPrefix; 
                                        if(i > 0 && diffSize > 1)
@@ -464,12 +467,16 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int
                                                // then write the distance amount of 00's
                                                if(diffSize > 1000) {
                                                        printf("WARNING! The distance to the next prefix is %i. Do you want to continue writing %i bytes of 0x00? Press y to continue", diffSize, diffSize);
                                                // then write the distance amount of 00's
                                                if(diffSize > 1000) {
                                                        printf("WARNING! The distance to the next prefix is %i. Do you want to continue writing %i bytes of 0x00? Press y to continue", diffSize, diffSize);
-                                                       if(getch() != 'y') {
+                                                       #ifdef _WIN32
+                                                       if ( _getch() != 'y' ) {
+                                                       #else
+                                                       if ( tty_getchar() != 'y' ) {
+                                                       #endif
                                                                printf("Aborting...");
                                                                exit(1);
                                                        }
                                                }
                                                                printf("Aborting...");
                                                                exit(1);
                                                        }
                                                }
-                                               for(int j = 1; j < diffSize; j++)
+                                               for(UINT4 j = 1; j < diffSize; j++)
                                                {                                                               
                                                        fwrite(&zero, 1, m_indexrowsizebytes, pFileIndex);
                                                }
                                                {                                                               
                                                        fwrite(&zero, 1, m_indexrowsizebytes, pFileIndex);
                                                }
@@ -612,7 +619,7 @@ int main(int argc, char* argv[])
                printf("no rainbow table found\n");
                return 0;
        }
                printf("no rainbow table found\n");
                return 0;
        }
-       for (int i = 0; i < vPathName.size(); i++)
+       for (UINT4 i = 0; i < vPathName.size(); i++)
        {
                string sResultFile;
                int n = vPathName[i].find_last_of('\\');
        {
                string sResultFile;
                int n = vPathName[i].find_last_of('\\');
@@ -629,4 +636,4 @@ int main(int argc, char* argv[])
                printf("\n");
        }
        return 0;
                printf("\n");
        }
        return 0;
-}
\ No newline at end of file
+}
diff --git a/Client Applications/converti2/makefile b/Client Applications/converti2/makefile
deleted file mode 100644 (file)
index 52bd857..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all: main
-
-main: 
-       g++ Public.cpp MemoryPool.cpp converti2.cpp -O3 -o converti2
-clean:
-       -rm *.o
-