lunedì 5 novembre 2018

NEMATODE BRAIN

A nematode has 302 neurons.
Can we replicate the brain of a nematode by an artificial neural network? 
I think we can't. The question is: the soul of the nematode is in those 302 neurons? Or not?
Is the nematode self conscious? If the nematode is not self conscious, it is only a machine.
If a nematode is not self conscious, a cat is self conscious? Why are we self conscious and a nematode not? Because we have more neurons?
Are we sure we are self conscious or we are only executing a complex alghorithm? 
How can a neuro contains part of a soul?
The model of an artificial neuron make sums, the signal of a single neuron is multiplied by a weight and summed with the other neurons on the same layer and at the result is applied a function, usually a sigmoid, probably a real neuron is more complicated, but not so complicated.
We believe, we hope to have a soul, we hope to be more than a machine, but we are only machines.
We are machine. We are not, until we act with humanity.
If you don't act with humanity, you are only a machine.

sabato 3 novembre 2018

WINDOWS MEMORY BUFFER EXECUTION

Executing a buffer of memory doesn't make sense on Windows, but you could face to this problem.
For example, if you play with Kali Linux, in this distribution you can find a tool called msfvenom, Basically it generaters payloads for metasploit framework and usually these payloads are backdoors.
A great payload is meterpreter, a backdoor that gives you total control of a remote host, you can also take pics from the webcam. 
Msfvenom has several encoders and you can use these encoders to crypt the payload. Now you are happy, you encrypt you payload, you create it for windows and when you put your windows executable in your windows machine, instantly your antivirus remove the file.
What's happening? You put you file on the disk, and zap! the antivirus removes it.
Nowaday antivirus recognize msfvenom even if you encrypt the payload, they recognize any msfvenom signature. What you can do is put your encrypted payload in a data file, Antiviruses usually don't scan data files, they scan only executables.
Once you have your meterpreter on a data file, you need  to load it from file and execute it.
On Windows you cannot execute directly from stack or from heap memory.
You can't do something that looks like:

unsigned char *code=malloc(...);
((void(*)())code)();

You have to use VirtualAlloc to be able to execute the code. VirtualAlloc is a low level API that permits to allocate memory for execution. 

char *code; 
code = (char *)VirtualAlloc( 
NULL, l, MEM_COMMIT,
PAGE_EXECUTE_READWRITE //Set the memory to be writable and executable
);
memcpy(code, payload, l); //Copy our payload into the executable section of memory
((void(*)())code)(); //execute the payload

That works, use gcc to compile.

venerdì 2 novembre 2018

MARKOV CHAINS AGAIN

Basically Markov chains can predict a sequence of states, if we have a matrix where columns are the states and row are the same states, for each state there is a row of the probability that the next state is that column, and the sum of the elements for each row is 1.
For example, if you consider a man that lives  in a big city, he can have only 4 states: sleep, eat, walking in the park and playing cards.
Markov chains can be used to predict the next state, for example, if the current state is sleeping, what is the probability that the next state is walking?

state/state sleep eat walking play cards
sleep0.20.40.30.1
eat0.10.20.60.1
walking0.20.20.30.2
play cards0.10.40.20.3

if the man sleep, probably the next state is eat (because is the more probable next event (0.4)),
if the man eat, probably the next state is walking, and so on.
This procedure can learn, because if the next state is not the state predicted, we can change the probabilities in the matrix and next time the predicted state will be different.
I know Markov chains was used in some chatter bots, in that case the states are one or more words, and the
sequence was a sequence of words. Training the chain with common phrases, the system was able
to produce phrases that made sense. Obviously the machine have no idea of the meaning of the phrase it is generating.
I'm still new in Markov Chains and I still have to assimilate the concept, but I'm sure it's powerful. I'm thinking about Markov chain these days to find some interesting application.
I started with neural networks, but they are heavy to use in python on a device like esp32, training requires too much cpu calculation.
I think Markov chains can be a simple alternative to neural networks, but they have to be used in the right way for the right application.