Tutti gli articoli di Walter Summonte

Curve Ellittiche in pratica

Ciao,

di seguito un semplice esempio di come utilizzare le curve ellittiche tramite il classico strumento openssl e i nostri classici amici Alice e Bob.

Alice e Bob generano le proprie chiavi pubbliche e private ti tipo ellittico


Creazione Chiavi


Alice:

openssl genpkey -algorithm  X25519 -out alice_privkey.pem
openssl pkey -in alice_privkey.pem -pubout -out alice_pubkey.pem

Bob:

openssl genpkey -algorithm  X25519 -out bob_privkey.pem
openssl pkey -in bob_privkey.pem -pubout -out bob_pubkey.pem

Cifra


Alice:

Alice genera una chiave EC temporanea e ne deriva un segreto usando la chiave pubblica di Bob

openssl genpkey -algorithm X25519 -out temp_privkey.pem
openssl pkeyutl -derive -inkey temp_privkey.pem -peerkey bob_pubkey.pem | base64 -w0 > secret.txt

(Attenzione, openssl tratta i dati da console come stringhe. Per evitare problemi di 0x00 presenti nella chiave, la convertiamo in base64)

Alice cifra il file per Bob con il segreto ottenuto
openssl enc -aes-256-cbc -in Testo.txt -out Testo.txt.enc -pass file:secret.txt

Alice genera la parte pubblica della chiave temporanea dalla quale Bob otterrà il segreto

openssl ecparam -in temp_privkey.pem -pubout -out temp_pubkey.pem

Alice invia a Bob il file cifrato Testo.txt.enc e la chiave pubblica temp_pubkey.pem

Decifra


Bob:

Bob usa la sua chiave privata ” bob_privkey.pem ” e la chiave pubblica ricevuta ” temp_pubkey.pem ” per derivare il segreto

openssh pkeyutl -derive -inkey bob_privkey.pem -peerkey temp_pubkey.pem | base64 -w0 > secret.txt

Bob decifra il testo cifrato

openssl enc -d -aes-256-cbc -in Testo.txt.enc -out Testo.txt -pass file:secret.txt

STEAM install on CENTOS7

To install Steam on a barebone Centos7 follow the next console commands:

yum install glibc.i686 libstdc++.i686 libgcc.i686
iptables -I INPUT -p udp –dport 27016 -j ACCEPT
iptables -I INPUT -p tcp –dport 27016 -j ACCEPT
iptables -I INPUT -p udp –dport 7778 -j ACCEPT
iptables -I INPUT -p tcp –dport 7778 -j ACCEPT
iptables -I INPUT -p tcp –dport 32330 -j ACCEPT

useradd -m steam
su – steam

mkdir steamcmd
cd steamcmd
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz

./steamcmd.sh

 

XML/XSD Estensione

Ciao,
mi è capitato di dover realizzare degli schemi XSD che potessero permettere l’aggiunta dinamica di tag. Il caso specifico era un elenco di periferiche presenti in un server dove ogni dispositivo aveva il proprio tag e dentro esso aveva la proprie caratteristiche.

Per ottenere ciò è utilizzabile il tag <xs:any>.


Aggiunta di “Qualunque dato” senza alcun controllo se non sintattico che i tag (se presenti) siano correttamente aperti e chiusi


Schema:

<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>
<xs:element name=”computer”>
<xs:annotation>
<xs:documentation xml:lang=”it-IT”>Definizione di un computer</xs:documentation>
<xs:documentation xml:lang=”en-US”>Definition of a computer</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name=”keyboard” />
<xs:element name=”mouse” />
<xs:element name=”monitor” />
<xs:any namespace=”##any” processContents=”lax” minOccurs=”0″ maxOccurs=”unbounded”/>
</xs:sequence>
</xs:complexType>
</xs:element>

Esempio:

<computer>
<keyboard>105 keys</keyboard>
<mouse>3 button</mouse>
<monitor>vga</monitor>
  <joystic>
     <mytag1>
        data1
        <mytag2 myattr=”asd”>
            myValue
        </mytag2>
     </mytag1>
  </joystic>
</computer>

 


Aggiunta di un estensione basata su uno schema esterno “senza alcun controllo” se non sintattico che i tag (se presenti) siano correttamente aperti e chiusi. Il controllo rispetto lo schema esterno deve essere fatto con una attività ulteriore separata.

Schema:

<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>
  <xs:complexType name=”myextraType”>
          <xs:sequence>
               <xs:any namespace=”##other” processContents=”lax” maxOccurs=”unbounded”/>
          </xs:sequence>
     </xs:complexType>
<xs:element name=”computer”>
<xs:annotation>
<xs:documentation xml:lang=”it-IT”>Definizione di un computer</xs:documentation>
<xs:documentation xml:lang=”en-US”>Definition of a computer</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name=”keyboard” />
<xs:element name=”mouse” />
<xs:element name=”monitor” />
<xs:element name=”myextra” type=”myextraType” minOccurs=”0″ maxOccurs=”unbounded”/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

 

Esempio:

<computer>
<keyboard>105 keys</keyboard>
<mouse>3 button</mouse>
<monitor>vga</monitor>
  <myextra xmlns:myExt=”http://personal.site/myExtensions.xsd”>
     <myExt:joystick>
        data1
        <myExt:mytag2 myattr=”asd”>
            myValue
        </myExt:mytag2>
     </myExt:joistick>
  </myextra>
</computer>

C# Password TextBox

Ciao,

di seguito il codice C# per l’estensione del componente TextBox al fine di mitigare il problema dei “keyLogger”.

Il codice è funzionante anche se sicuramente prototipale.

Spero possa esservi utile.

(Codice presso GitHub: https://github.com/waltzie/CSharp-PasswordTextBox)

using System;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
namespace WaltZie.Windows.Forms
{

///
/// Estensione della casella TextBox per gestire le password in modo che non possano essere intercettate dai keylkoggers
///

// Problema con i caratteri [] gestiti da sendkey
// Problema con digitazione caratteri in contemporanea. Occorre reindirizzare OnKeyPress a thread sequenziali.

public class PasswordTextBox : System.Windows.Forms.TextBox
{
public static PasswordTextBox Instance = new PasswordTextBox();

private string junk = “”;
private uint _junkMax = 4;
private uint _junkMin = 2;
private byte _minchar = 32;
private byte _maxchar = 126;
private string _allowedchars=””;
private string _scramble;
private bool _obfuscate = false;

private static readonly Random random = new Random();
private static readonly object syncLock = new object();
private delegate string del(string s);

public PasswordTextBox() {
}

protected override void OnMouseDown(MouseEventArgs e)
{
if (String.IsNullOrEmpty(this.Text))
{
sendJunkChars();
}
base.OnMouseDown(e);
}

///
///
The AllowedChars represents characters allowed.

/// The AllowedChars gets/sets the value of the string field, _allowedchars.
///
[Category(“Extensions”), Browsable(true), Description(“String containig allowed chars”)]
public string AllowedChars
{
set
{
if ((value.Length) < 256) { this._allowedchars = value; this._scramble = new string(_allowedchars.ToCharArray().OrderBy(x => Guid.NewGuid()).ToArray());
}
}
get
{
return this._allowedchars;
}
}

///
///
The Obfuscate define if typed text must be obfuscate with shuffled allowd chars.

/// The Obfuscate gets/sets the value of the bool field, _obfuscate.
///
[Category(“Extensions”), Browsable(true), Description(“Obfuscate input data”)]
public bool Obfuscate
{
set
{
this._obfuscate = value;
if (this._obfuscate && _allowedchars == “”) this.AllowedChars = ” !\”#$%&'()*+-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~”;
}
get
{
return this._obfuscate;
}
}

///
///
The ClearText represents real typed test.

/// The ClearText gets the value of the de-obfuscated string field, Text.
/// Returns original de-obfuscated typed text.
///
[Category(“Extensions”), Browsable(true), Description(“Clear text”)]
public string ClearText
{
get
{
return deobfuscate(this.Text);
}
}

private bool IsAllowedChar(char c)
{
if (char.IsControl(c)) return false;
if (this._allowedchars.Length > 0)
{
if (this._allowedchars.Contains(c.ToString())) return true;
else return false;
}
else return true;
}

private string Randomchar()
{
return Convert.ToChar(random.Next(this._minchar, this._maxchar)).ToString();
}

private string junkGenerator()
{
string randomString = “”;
for (int i = 0; i < random.Next((int)this._junkMin, (int)this._junkMax); i++)
randomString += Randomchar();
return randomString;
}
private void sendJunkChars()
{
string outchar = “”;
lock (syncLock)
{
this.junk += junkGenerator();
for (int i = 0; i < this.junk.Length; i++)
if (“+^%~(){}”.Contains(this.junk[i])) outchar += “{” + this.junk[i] + “}”;
else outchar += this.junk[i].ToString();
this.Focus();
SendKeys.Send(outchar);
}
}

private char obfuscate(char s) {
lock (syncLock)
{
if (this._obfuscate) return this._scramble[this._allowedchars.IndexOf(s)];
else return s;
}
}
private string deobfuscate(string s) {
if (!this._obfuscate) return s;
string outstr = “”;
for (int i=0; i<this.Text.Length;i++) { outstr += this._allowedchars[this._scramble.IndexOf(this.Text[i])].ToString(); } return outstr; } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (this.junk.Length == 0) { if (keyData == Keys.Delete) OnKeyPress(new KeyPressEventArgs((Char)Keys.Back)); } return base.ProcessCmdKey(ref msg, keyData); } protected override void OnKeyPress(KeyPressEventArgs e) { // Controllare this.SelectedText base.OnKeyPress(e); string keyInput = e.KeyChar.ToString(); if (this.junk.Length > 0)
{
//this char is junk
e.Handled = true;
lock(syncLock) this.junk = this.junk.Remove(this.junk.Length – 1);
}
else if (IsAllowedChar(e.KeyChar))
{
e.KeyChar = obfuscate(e.KeyChar);
sendJunkChars();
}
else if (e.KeyChar == ‘\b’)
{
try
{
// Backspace key is OK
sendJunkChars();
}
catch { e.Handled = true; }
}
else
{
// Consume this invalid key and beep
e.Handled = true;
System.Media.SystemSounds.Exclamation.Play();
}
}
}
}

Quale wiki fà per te?

Per l’organizzazione dei dati lavorativi personali e non, è comune riempire il proprio spazio disco di cartelle e file. Questo metodo sebbene rapido, non è di facile gestione, soprattutto nella ricerca e catalogazione delle informazioni. Senza parlare poi dei semilavorati come le le bozze. Inoltre, resta sempre perenne il rischio di rottura dei supporti che richiederebbe un sistema di gestione dei backup e degli allineamenti.

Questo ha portato l’evoluzione dei CMS (Content Management Systems) in particolar modo di quelli basati sul famoso WiKi in tantissime varianti.

Nel caso in cui foste interessati a trovare il CMS stile WiKi che fà per voi, vi suggerisco di dare un’occhiata al seguente sito che permette tramite una funzione di ricerca di identificare i tools che rispondano alle vostre esigenze.

http://www.wikimatrix.org/