Browse Source

Re-factored for CodeDweller separation

git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@4 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist 15 years ago
parent
commit
7faa99d01f
15 changed files with 27 additions and 166 deletions
  1. 1
    1
      SNFMulti.cpp
  2. 2
    2
      SNFMulti.hpp
  3. 0
    106
      mangler.cpp
  4. 0
    34
      mangler.hpp
  5. 2
    2
      snfCFGmgr.hpp
  6. 2
    2
      snfGBUdbmgr.hpp
  7. 2
    2
      snfLOGmgr.cpp
  8. 4
    3
      snfLOGmgr.hpp
  9. 2
    2
      snfNETmgr.cpp
  10. 4
    4
      snfNETmgr.hpp
  11. 3
    3
      snfXCImgr.hpp
  12. 1
    1
      snf_engine.cpp
  13. 1
    1
      snf_engine.hpp
  14. 2
    2
      snf_sync.hpp
  15. 1
    1
      snf_xci.hpp

+ 1
- 1
SNFMulti.cpp View File

@@ -15,7 +15,7 @@

#include <sstream>
#include "SNFMulti.hpp"
#include "timing.hpp"
#include "../CodeDweller/timing.hpp"

//#include "../nvwa-0.6/nvwa/debug_new.h"


+ 2
- 2
SNFMulti.hpp View File

@@ -29,15 +29,15 @@
#include <sys/stat.h>
#include <ctime>
#include <string>
#include "../CodeDweller/threading.hpp"
#include "GBUdb.hpp"
#include "FilterChain.hpp"
#include "snf_engine.hpp"
#include "snf_match.h"
#include "threading.hpp"
#include "snfCFGmgr.hpp"
#include "snfLOGmgr.hpp"
#include "snfNETmgr.hpp"
#include "snfGBUdbmgr.hpp"
#include "GBUdb.hpp"
#include "snfXCImgr.hpp"

#include <cassert>

+ 0
- 106
mangler.cpp View File

@@ -1,106 +0,0 @@
// MANGLER.CPP
//
// (C) 1984-2009 MicroNeil Research Corporation
// Derived from Version 1 of Mangler Encryption Algorythm, 1984.
// Derived from Version 2 of Mangler Encryption Algorythm, 1998.
//

// 20021008 _M
// Found and corrected range bug in ChaosDriver(void) where
// ~Position might access a location outside the fill. Replaced
// ~Position with Position^0xff which has the intended effect.

// 20020119 _M Version 3.0
//
// Mangler encryption engine object.
// Using new optimized chaos driver for uniformity experiments.
// Important in this experiment is proof of highest possible entropy.

#include "mangler.hpp"

unsigned char MANGLER::ChaosDriver(void) { // Return the current
return Fill[Fill[Position]^Fill[Position^0xff]]; // chaos engine output
} // value.

// As of version 3 the output of the chaos driver was strengthened for
// cryptography and to increase the sensitivity of the output for use
// as a random number generator. In version 2, the software would simply
// return the fill value at the engine's current position. In the new
// version two distinct fill values are involved in abstracting the
// value of Position and determining the final output value and the Position
// value itself is used to add complexity to the output.

unsigned char MANGLER::Rotate(unsigned char i) { // Bitwise rotates i
return (
(i & 0x80)? // This operation is
(i<<1)+1: // described without
(i<<1) // using asm.
);
}

void MANGLER::ChaosDriver(unsigned char i) { // Drives chaos engine.

// First we move our mixing position in the fill buffer forward.

Position=( // Move mixing position.
Position+1+ // Move at least 1, then
(Fill[Position]&0x0f) // maybe a few more.
)%256; // But stay within the fill.

// The fill position in version 2 was simply incremented. This allowed
// for an attacker to predict something important about the state of
// the chaos engine. The new method above uses abstraction through the
// fill buffer to introduce "jitter" when setting a new position based
// on data that is hidden from the outside.

// Next we abstract the incoming character through the fill buffer and
// use it to select fill data to rotate and swap.

unsigned char Swap = ((Fill[Position]^Fill[i])+Position+i)%256;
unsigned char Tmp;

Tmp = Fill[Swap];
Fill[Swap]=Fill[Position];
Fill[Position]=Rotate(Tmp);

// Whenever the Swap and Path positions are the same, the result is
// that no data is swapped in the chaos field. We resolve that by
// recalling the ChaosDriver. This has the added effect of increasing
// the complexity and making it more difficult to predict the state
// of the engine... particularly because the engine evloves to a new
// state under these conditions without having exposed that change
// to the outside world.

if(Position==Swap) ChaosDriver(Tmp); // If we didn't swap, recurse.

}

// The encryption / decryption scheme works by modulating an input data
// stream with a chaotic system and allowing the encrypted stream to drive
// the chaotic system of both the transmitter and receiver. This will
// synchronize the two chaotic systems and allow the receiving system to
// "predict" the state of the transmiting system so that it can properly
// demodulate the encrypted stream. Both chaotic systems must start in the
// same state with the same fill data characteristics or else the two
// chaotic systems evolve to further divergent states.

unsigned char MANGLER::Encrypt(unsigned char i) {
unsigned char g = ChaosDriver() ^ i; // Take the output of the
ChaosDriver(g); // chaos engine and use it
return g; // to moduleate the input.
} // Then drive the engine
// with the encrypted data.

unsigned char MANGLER::Decrypt(unsigned char i) {
unsigned char g = ChaosDriver() ^ i; // Take the output of the
ChaosDriver(i); // chaos engine and use it
return g; // to demodulate the input.
} // then drive the engine
// with the original input.
MANGLER::MANGLER(void) {
for(short c = 0;c<256;c++) // The default constructor sets
Fill[c]=(unsigned char) c; // the key to the root primary
Position = 0; // value and Position to 0.
}



+ 0
- 34
mangler.hpp View File

@@ -1,34 +0,0 @@
// MANGLER.HPP
//
// (C) 1984-2009 MicroNeil Research Corporation
// Derived from Version 1 of Mangler Encryption Algorythm, 1984.
// Derived from Version 2 of Mangler Encryption Algorythm, 1998.
//
// 20020119 _M Mangler V3.
// Mangler object header file.
// If it's already been included, it doesn't need to be included again.

#ifndef _MANGLER_
#define _MANGLER_

class MANGLER {
private:

unsigned char Fill[256]; // Where to store the fill.
unsigned int Position; // Where to put position.

unsigned char Rotate(unsigned char); // Bitwise Rotate Utility.

unsigned char ChaosDriver(void); // Returns current chaos.
void ChaosDriver(unsigned char i); // Drives chaos forward.

public:

unsigned char Encrypt(unsigned char i); // Returns encrypted data.
unsigned char Decrypt(unsigned char i); // Returns decrypted data.

MANGLER(void); // Default.
};

#endif


+ 2
- 2
snfCFGmgr.hpp View File

@@ -12,8 +12,8 @@
#include "GBUdb.hpp"
#include "snf_HeaderFinder.hpp"

#include "configuration.hpp"
#include "threading.hpp"
#include "../CodeDweller/configuration.hpp"
#include "../CodeDweller/threading.hpp"
#include <string>
#include <set>


+ 2
- 2
snfGBUdbmgr.hpp View File

@@ -9,8 +9,8 @@
#ifndef snfGBUdbmgr_included
#define snfGBUdbmgr_included

#include "threading.hpp"
#include "timing.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/timing.hpp"
#include "snfCFGmgr.hpp"
#include "snfLOGmgr.hpp"
#include "GBUdb.hpp"

+ 2
- 2
snfLOGmgr.cpp View File

@@ -6,8 +6,8 @@
// Log Manager implementations see snfLOGmgr.hpp for details.

#include "snfLOGmgr.hpp"
#include "threading.hpp"
#include "timing.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/timing.hpp"
#include <unistd.h>

using namespace std;

+ 4
- 3
snfLOGmgr.hpp View File

@@ -19,15 +19,16 @@
#include <ctime>
#include <cstdio>

#include "timing.hpp"
#include "threading.hpp"
#include "../CodeDweller/timing.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/histogram.hpp"

#include "snf_match.h"

#include "snfCFGmgr.hpp"
#include "snfNETmgr.hpp"
#include "GBUdb.hpp"

#include "histogram.hpp"

class snfNETmgr; // Declare snfNETmgr
extern const char* SNF_ENGINE_VERSION; // Declare the Engine Version Data

+ 2
- 2
snfNETmgr.cpp View File

@@ -15,8 +15,8 @@
#include <sstream>
#include "snfNETmgr.hpp"
#include "snf_sync.hpp"
#include "mangler.hpp"
#include "base64codec.hpp"
#include "../CodeDweller/mangler.hpp"
#include "../CodeDweller/base64codec.hpp"
// #include "tcp_watchdog.hpp" No longer using TCPWatchdog -- see below _M

using namespace std;

+ 4
- 4
snfNETmgr.hpp View File

@@ -12,13 +12,13 @@

#include <stdexcept>
#include <vector>
#include "networking.hpp"
#include "timing.hpp"
#include "threading.hpp"
#include "../CodeDweller/networking.hpp"
#include "../CodeDweller/timing.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/mangler.hpp"
#include "snfCFGmgr.hpp"
#include "snfLOGmgr.hpp"
#include "snfGBUdbmgr.hpp"
#include "mangler.hpp"

class snfScanData; // Declare snfScanData;
class snfLOGmgr; // Declare snfLOGmgr;

+ 3
- 3
snfXCImgr.hpp View File

@@ -10,9 +10,9 @@

#include <string>
#include <queue>
#include "timing.hpp"
#include "threading.hpp"
#include "networking.hpp"
#include "../CodeDweller/timing.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/networking.hpp"
#include "snf_xci.hpp"

using namespace std;

+ 1
- 1
snf_engine.cpp View File

@@ -34,7 +34,7 @@
#include <fstream>
#include <iostream>
#include <string>
#include "mangler.hpp"
#include "../CodeDweller/mangler.hpp"
#include "snf_engine.hpp"

using namespace std;

+ 1
- 1
snf_engine.hpp View File

@@ -40,7 +40,7 @@
#include <iostream>
#include <string>
#include <exception>
#include "mangler.hpp"
#include "../CodeDweller/mangler.hpp"
//#include "../nvwa-0.6/nvwa/debug_new.h"

using namespace std;

+ 2
- 2
snf_sync.hpp View File

@@ -12,8 +12,8 @@
#include <list>
#include <cstring>
#include "GBUdb.hpp"
#include "networking.hpp"
#include "configuration.hpp"
#include "../CodeDweller/networking.hpp"
#include "../CodeDweller/configuration.hpp"

class GBUAlertHandler : public Configurator {
public:

+ 1
- 1
snf_xci.hpp View File

@@ -14,7 +14,7 @@
#ifndef snf_xci_included
#define snf_xci_included

#include "configuration.hpp"
#include "../CodeDweller/configuration.hpp"

class snf_xci { // SNF XCI message interpreter.
private:

Loading…
Cancel
Save