mercoledì 27 marzo 2019

ESP32 AND C#

I installed nanoframework in Visual Studio 2017 and I can program ESP32 using C#.
The API for ESP32 is quite limited and with Arduino IDE you can do much more, but C# is high level programming language,  it's highly OOP oriented and it's a good solution  for complex applications. ESP32 has a lot of memory and double core CPU. If you use it with LUA or javascipt you are limited  by the language.
Also, if you have a ESP32 board with JTAG, you can  use the step by step debugger of Visual Studio.
You have to download a specific firmware on ESP32 to make it  work with nanoframework, the firmware is in nanoframework git repository.

domenica 27 gennaio 2019

SPARKFUN MICRO PRO


Dear friends,
I was  googling about how  to  use esp32 like  a usb  keyboard, but it doesn't seem feasible and youncan't use  the  arduino keyboard  library.
It seems only certain arduinos can use keyboard  library: Leonardo, micro, arduino 2, mkr serie.
I opted for sparkfun micro pro, because I found it in  the electronic  shop behind the corner.
At first glance I was very surprised for the size,  it's incredible  small, apart  that, keyboard libraries  works  perfectly on it.
You will wonder why am I interested  in such a device?
The reason is because I red of a device  called bash bunny.
That'an interesting concept,  because the idea of simply connect to the computer an usb keyboard and automagically control  it is the fantasy of my childhood and it  is used  in many Hollywood movies.
In past  I thought to simulate a cdrom with  an  arduino, because  it you pur certain  files  on a cdrom  the  old versions  of windows  executed it when you3 inserted the  cdrom  without asking, but  the latest  versions of windows  asks.
Basically  as usb  key  emulator you can do anything on the computer. You  can login, activate the command prompt or the  powershell  prompt  and write your  program and execute  it. Top can have the total control  of the system.
For example it you want to start  the command  prompt, voi nave to use this code:
include "Keyboard.h"
...
Keyboard.begin();
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.releaseAll();
delay(2000);
Keyboard.press(KEY_RETURN);
Keyboard.releaseAll();
delay(2000);
Now you can write your commands
...
It you want to type many characters, you need an  sd reader to  connect to  the micro pro. Usually sd card  readers requires 5volt.  You  can  use  the  usb  to  obtain this Voltage. I bought the 3.3 volts  version  of the micro  pro because I wanted to connect  it to the esp32, but there is also  a 5v version.

sabato 19 gennaio 2019

FACE EDITOR

Hey guys,
I found a program that uses unsupervised learning neural network to generate random faces.
https://github.com/HackerPoet/FaceEditor
These faces are not faces of real people, these are faces of unexisting people. You click a button and it generates a random face,then you can change this face using many switches.
These are some faces I generated:

What happens if someone put a unexisting face in a fake facebook profile?


sabato 29 dicembre 2018

NEURONA


This is an ESP32 board with OLED display. It's cool.
I was trying to program this board by Zerynth Studio, but the display on this board uses I2C, while the libraries for Zerynth Studio works only with SPI interface. In order to avoid to manage the I2C protocol from the base class, I had to move to Arduino IDE and forget Python.
Has been a long time since I used Arduino Ide and I discovered an interesting neural network implementation, it is distributed as Arduino library: Neurona.
This library implements a supervised neural network for Arduino boards and also it works for ESP32, my crush board. The usage of the library is quite simple, you initialize it with the number of inputs, the number of hidden layers and the number of outputs. You have to provide the trained weights, it does not train on Arduino, you have to use an external software to train the network and obtains the weight, then you pass the weight to the library.

sabato 15 dicembre 2018

EVOLUTION FOR ANDROID

I found this app on  Google Play:
You can build a creature by adding joints,  bones and muscles.
The game uses neural network to evolve your creature to walk,  jump  and avoid obstacles.
It's very funny and additive.

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.