fork download
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. class Program
  5. {
  6. static void Main(string[] args)
  7. {
  8. if (args.Length < 6)
  9. {
  10. Console.WriteLine("Uso: program <ssh_host> <ssh_user> <local_port> <remote_port> <certkey> <sshExe>");
  11. return;
  12. }
  13.  
  14. string sshHost = args[0]; // Host do servidor SSH
  15. string sshUser = args[1]; // Usuário SSH
  16. string localPort = args[2]; // Porta local
  17. string remotePort = args[3]; // Porta remota
  18. string certkey = args[4];
  19. string sshExe = args[5];
  20.  
  21. string sshPassword = "senha"; // Gerenciar senha de maneira segura
  22. string command = $"{sshExe} -ssh {sshUser}@{sshHost} -pw {sshPassword} -L {localPort}:localhost:{remotePort} -i {certkey}";
  23.  
  24. // Executa o comando
  25. Process.Start(new ProcessStartInfo
  26. {
  27. FileName = "cmd.exe",
  28. Arguments = "/C " + command,
  29. CreateNoWindow = true,
  30. UseShellExecute = false
  31. });
  32.  
  33. Console.WriteLine("Túnel SSH aberto.");
  34. }
  35. }
  36.  
Success #stdin #stdout 0.05s 29008KB
stdin
/*  Berechnung des Hamming-Abstandes zwischen zwei 128-Bit Werten in 	*/
/*	einer Textdatei. 													*/
/*  Die Werte müssen auf einer separaten Zeile gespeichert sein			*/
/* 																		*/
/*	Erstellt: 17.5.2010													*/
/*  Autor: Thomas Scheffler												*/

#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE 32

unsigned Hamdist(unsigned x, unsigned y)
{
  unsigned dist = 0, val = x ^ y;
 
  // Count the number of set bits
  while(val)
  {
    ++dist; 
    val &= val - 1;
  }
 
  return dist;
}



int main (void)
{
	char hex;
	int i;
	int a[ARRAY_SIZE];
	int b[ARRAY_SIZE];
	int hamDist = 0;
	FILE* fp;
	
	//Arrays mit 0 initialisieren
	for (i = 0; i < ARRAY_SIZE; ++i)
	{
  		a[i] = 0;
  		b[i] = 0;
	}

	
	fp = fopen("hex.txt","r");
	if (fp == NULL) 
	{
		printf("Die Datei hex.txt wurde nicht gefunden!");
		exit(EXIT_FAILURE);
	}

	i=0;
	printf("1.Zeile einlesen.\n");

 	while((hex=fgetc(fp))!='\n' && hex != EOF)
    {
        a[i]=strtol(&hex,0,16);
		i++;
    }
	i=0;
	printf("2.Zeile einlesen.\n");

 	while((hex=fgetc(fp))!='\n' && hex != EOF)
    {
    	b[i]=strtol(&hex,0,16);
        i++;
    }
	fclose(fp);

	printf("Hamming-Abweichung pro Nibble:\n");
	for (i = 0; i < ARRAY_SIZE; ++i)
	{
		printf ("%i\t%i\t%i\n",a[i],b[i],Hamdist(a[i],b[i]));
		hamDist += Hamdist(a[i],b[i]);
	}
	printf ("\nHamming-Abweichung der Hash-Werte:%d\n",hamDist);
}

stdout
Uso: program <ssh_host> <ssh_user> <local_port> <remote_port> <certkey> <sshExe>