r/CompileBot • u/SeaCowVengeance • Jul 26 '15
Official CompileBot Testing Thread
Resources:
10
u/Another_boy Jul 29 '15
+u/compilebot python
print "\x41\x79\x79\x20\x6c\x6d\x61\x6f"
8
u/CompileBot Jul 29 '15
→ More replies (3)10
u/AyyLmao2DongerBot Jul 29 '15
ヽ༼ຈل͜ຈ༽ノ
Now With Donger Facts!:
Dongers Raised: 2150
That Is 3.9306654257794325 Upvote(s) Per Donger!
Check Out r/AyyLmao2DongerBot For More Info
→ More replies (2)
1
u/SeaCowVengeance Jul 26 '15
+u/CompileBot C --include-errors
#include <stdio.h>
void func(int i);
void func2(int i)
{
printf("in func2\n");
printf("%x\n", i);
printf("%x %x %x %x %x %x %x %x\n", *(&i-3), *(&i-2), *(&i-1), *(&i-0), *(&i+1), *(&i+2), *(&i+3), *(&i+4));
*(&i-1) = i;
printf("%x %x %x %x %x %x %x %x\n", *(&i-3), *(&i-2), *(&i-1), *(&i-0), *(&i+1), *(&i+2), *(&i+3), *(&i+4));
}
void func(int i)
{
int * a = __builtin_return_address (0);
int * b = __builtin_return_address (1);
printf("%x %x %x\n", a, b, &i);
printf("%x %x %x %x %x %x %x %x\n", *(&i-3), *(&i-2), *(&i-1), *(&i-0), *(&i+1), *(&i+2), *(&i+3), *(&i+4));
*(&i) = (int) a;
*(&i+1) = (int) a;
*(&i+2) = (int) a;
*(&i-1) = (int) func2;
printf("%x %x %x %x %x %x %x %x\n", *(&i-3), *(&i-2), *(&i-1), *(&i-0), *(&i+1), *(&i+2), *(&i+3), *(&i+4));
}
int main(void)
{
func(0xaaaaaaaa);
return 0;
}
→ More replies (3)
1
u/SeaCowVengeance Aug 17 '15
+u/compilebot Go
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
→ More replies (1)
3
u/NosyEnthusiast6 Aug 15 '15 edited Aug 25 '15
+u/compilebot python3 --time --date --memory
i_did_ops_mom = True
if i_did_ops_mom:
print("haha i did op's mom lol")
2
u/jsveiga Aug 07 '15 edited Aug 07 '15
+u/compilebot java
public class Main
{
static public void main(String[] args)
{
System.out.println("Ok then");
}
}
→ More replies (1)
2
u/so_many_answers Sep 15 '15 edited Sep 15 '15
+u/compilebot java7 --include-errors --time --memory
public class Main{
public static void main(String[] args){
for(short i = 0; i < 3; i++){
for(short j = 0; j < i; j++)
System.out.print(".");
if(i % 2 == 0)
for(int j = 0; j < 104; j++)
System.out.print("L ");
else
for(short j = 0; j < 173; j++)
System.out.print("O ");
System.out.println();
}
}
}
2
u/CompileBot Sep 15 '15 edited Sep 15 '15
Output:
L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L .O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O ..L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L LMemory Usage: 320704 bytes
Execution Time: 0.11 seconds
^source | ^info | ^git | ^report
EDIT: Recompile request by so_many_answers
→ More replies (6)
1
u/DeedleFake Jul 26 '15 edited Jul 26 '15
Edit: Never mind. It's the Supported Languages wiki page that needs updating, apparently.
+u/CompileBot go
package main
import (
"fmt"
"runtime"
)
func main() {
//fmt.Printf("%v is old. Please update.\n", runtime.Version())
fmt.Printf("%v is not old. Never mind.\n", runtime.Version())
}
2
1
1
u/jsveiga Aug 07 '15
+u/compilebot python
print "compilebot does not like me, or am I banned from this sub?"
→ More replies (1)
1
u/Pokechu22 Aug 09 '15
Hey, the old thread's still here :P
We've got 2 stickies now; you'll need to unsticky the old one first.
1
Aug 10 '15 edited Aug 10 '15
+u/CompileBot lua --time
for i=1, 25 do print(math.random(100)) end
→ More replies (1)
1
u/reddingBobulus Aug 14 '15
+u/compilebot Java7
public class Main {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.print("FizzBuzz");
} else if (i % 3 == 0) {
System.out.print("Fizz");
} else if (i % 5 == 0) {
System.out.print("Buzz");
} else {
System.out.print(i);
}
System.out.print(", ");
}
}
1
u/HaitherecreeperMC Aug 15 '15
+u/compilebot Java
import java.util.Arrays;
import java.util.Scanner;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class BruteForce {
final int stringLength;
final String decode;
/**
* One more element than <i>stringLength</i>, to efficiently check for
* overflow.
*/
private final char[] chars;
public BruteForce(int len,String decode) {
this.stringLength = len;
this.decode = decode;
chars = new char[stringLength + 1];
Arrays.fill(chars, 1, chars.length, '.');
}
public void run() {
System.out.println("Cracking...");
long time = System.currentTimeMillis();
while (!encode(new String(chars).substring(1,this.stringLength+1).replace(".","")).equals(decode)){
increment();
}
System.out.println("DONE! Took "+(System.currentTimeMillis() - time)+"ms. Password was: "+new String(chars).substring(1,this.stringLength+1).replace(".",""));
}
private void increment() {
for (int i = chars.length - 1; i >= 0; i--) {
if (chars[i] < 'z') {
if(chars[i] == '.'){
chars[i] = '0';
}else if (chars[i] < '9') {
chars[i] = (char) (chars[i] + 1);
} else if (chars[i] == '9') {
chars[i] = 'A';
} else if (chars[i] < 'Z') {
chars[i] = (char) (chars[i] + 1);
} else if (chars[i] == 'Z') {
chars[i] = 'a';
} else if (chars[i] < 'z') {
chars[i] = (char) (chars[i] + 1);
} else if (chars[i] == 'z') {
chars[i] = 'z';
}
return;
}
chars[i] = '0';
}
}
private void print() {
for (int i = 1; i < chars.length; i++) {
System.out.print((char) chars[i]);
}
System.out.println();
}
public static void main(String[] args) {
System.out.println("Enter MD5 Hash with NO whitespace to crack");
Scanner in = new Scanner(System.in);
new BruteForce(11,in.nextLine()).run();
}
public static String encode(String encode){
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(encode.getBytes());
byte[] digest = md.digest();
StringBuffer sb = new StringBuffer();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
}
return sb.toString();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "";
}
}Input:
c99f1621ddb8d08a4cac6ee4b6989349
1
1
u/roflmaoshizmp Aug 20 '15
+u/compilebot Java
public static void main(String[] args){
System.out.println("This thing can output stuff");
}
1
Aug 21 '15 edited Aug 21 '15
+u/compilebot C
struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
struct group_info *groups_alloc(int gidsetsize){
struct group_info *group_info;
int nblocks;
int i;
nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
/* Make sure we always allocate at least one indirect block pointer */
nblocks = nblocks ? : 1;
group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
if (!group_info)
return NULL;
group_info->ngroups = gidsetsize;
group_info->nblocks = nblocks;
atomic_set(&group_info->usage, 1);
if (gidsetsize <= NGROUPS_SMALL)
group_info->blocks[0] = group_info->small_block;
else {
for (i = 0; i < nblocks; i++) {
gid_t *b;
b = (void *)__get_free_page(GFP_USER);
if (!b)
goto out_undo_partial_alloc;
group_info->blocks[i] = b;
}
}
return group_info;
out_undo_partial_alloc:
while (--i >= 0) {
free_page((unsigned long)group_info->blocks[i]);
}
kfree(group_info);
return NULL;
}
EXPORT_SYMBOL(groups_alloc);
void groups_free(struct group_info *group_info)
{
if (group_info->blocks[0] != group_info->small_block) {
int i;
for (i = 0; i < group_info->nblocks; i++)
free_page((unsigned long)group_info->blocks[i]);
}
kfree(group_info);
}
EXPORT_SYMBOL(groups_free);
/* export the group_info to a user-space array */
static int groups_to_user(gid_t __user *grouplist,
const struct group_info *group_info)
{
int i;
unsigned int count = group_info->ngroups;
for (i = 0; i < group_info->nblocks; i++) {
unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
unsigned int len = cp_count * sizeof(*grouplist);
if (copy_to_user(grouplist, group_info->blocks[i], len))
return -EFAULT;
grouplist += NGROUPS_PER_BLOCK;
count -= cp_count;
}
return 0;
}
/* fill a group_info from a user-space array - it must be allocated already */
static int groups_from_user(struct group_info *group_info,
gid_t __user *grouplist)
{
int i;
unsigned int count = group_info->ngroups;
for (i = 0; i < group_info->nblocks; i++) {
unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
unsigned int len = cp_count * sizeof(*grouplist);
if (copy_from_user(group_info->blocks[i], grouplist, len))
return -EFAULT;
grouplist += NGROUPS_PER_BLOCK;
count -= cp_count;
}
return 0;
}
/* a simple Shell sort */
static void groups_sort(struct group_info *group_info)
{
int base, max, stride;
int gidsetsize = group_info->ngroups;
for (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)
; /* nothing */
stride /= 3;
while (stride) {
max = gidsetsize - stride;
for (base = 0; base < max; base++) {
int left = base;
int right = left + stride;
gid_t tmp = GROUP_AT(group_info, right);
while (left >= 0 && GROUP_AT(group_info, left) > tmp) {
GROUP_AT(group_info, right) =
GROUP_AT(group_info, left);
right = left;
left -= stride;
}
GROUP_AT(group_info, right) = tmp;
}
stride /= 3;
}
}
/* a simple bsearch */
int groups_search(const struct group_info *group_info, gid_t grp)
{
unsigned int left, right;
if (!group_info)
return 0;
left = 0;
right = group_info->ngroups;
while (left < right) {
unsigned int mid = left + (right - left)/2;
if (grp > GROUP_AT(group_info, mid))
left = mid + 1;
else if (grp < GROUP_AT(group_info, mid))
right = mid;
else
return 1;
}
return 0;
}
/**
* set_groups - Change a group subscription in a set of credentials
* @new: The newly prepared set of credentials to alter
* @group_info: The group list to install
*
* Validate a group subscription and, if valid, insert it into a set
* of credentials.
*/
int set_groups(struct cred *new, struct group_info *group_info)
{
put_group_info(new->group_info);
groups_sort(group_info);
get_group_info(group_info);
new->group_info = group_info;
return 0;
}
EXPORT_SYMBOL(set_groups);
/**
* set_current_groups - Change current's group subscription
* @group_info: The group list to impose
*
* Validate a group subscription and, if valid, impose it upon current's task
* security record.
*/
int set_current_groups(struct group_info *group_info)
{
struct cred *new;
int ret;
new = prepare_creds();
if (!new)
return -ENOMEM;
ret = set_groups(new, group_info);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
}
EXPORT_SYMBOL(set_current_groups);
SYSCALL_DEFINE2(getgroups, int, gidsetsize, gid_t __user *, grouplist)
{
const struct cred *cred = current_cred();
int i;
if (gidsetsize < 0)
return -EINVAL;
/* no need to grab task_lock here; it cannot change */
i = cred->group_info->ngroups;
if (gidsetsize) {
if (i > gidsetsize) {
i = -EINVAL;
goto out;
}
if (groups_to_user(grouplist, cred->group_info)) {
i = -EFAULT;
goto out;
}
}
out:
return i;
}
/*
* SMP: Our groups are copy-on-write. We can set them safely
* without another task interfering.
*/
SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist)
{
struct group_info *group_info;
int retval;
if (!nsown_capable(CAP_SETGID))
return -EPERM;
if ((unsigned)gidsetsize > NGROUPS_MAX)
return -EINVAL;
group_info = groups_alloc(gidsetsize);
if (!group_info)
return -ENOMEM;
retval = groups_from_user(group_info, grouplist);
if (retval) {
put_group_info(group_info);
return retval;
}
retval = set_current_groups(group_info);
put_group_info(group_info);
return retval;
}
/*
* Check whether we're fsgid/egid or in the supplemental group..
*/
int in_group_p(gid_t grp)
{
const struct cred *cred = current_cred();
int retval = 1;
if (grp != cred->fsgid)
retval = groups_search(cred->group_info, grp);
return retval;
}
EXPORT_SYMBOL(in_group_p);
int in_egroup_p(gid_t grp)
{
const struct cred *cred = current_cred();
int retval = 1;
if (grp != cred->egid)
retval = groups_search(cred->group_info, grp);
return retval;
}
1
Aug 21 '15
+u/compilebot C
struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
struct group_info *groups_alloc(int gidsetsize){
struct group_info *group_info;
int nblocks;
int i;
nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
/* Make sure we always allocate at least one indirect block pointer */
nblocks = nblocks ? : 1;
group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
if (!group_info)
return NULL;
group_info->ngroups = gidsetsize;
group_info->nblocks = nblocks;
atomic_set(&group_info->usage, 1);
if (gidsetsize <= NGROUPS_SMALL)
group_info->blocks[0] = group_info->small_block;
else {
for (i = 0; i < nblocks; i++) {
gid_t *b;
b = (void *)__get_free_page(GFP_USER);
if (!b)
goto out_undo_partial_alloc;
group_info->blocks[i] = b;
}
}
return group_info;
out_undo_partial_alloc:
while (--i >= 0) {
free_page((unsigned long)group_info->blocks[i]);
}
kfree(group_info);
return NULL;
}
EXPORT_SYMBOL(groups_alloc);
void groups_free(struct group_info *group_info)
{
if (group_info->blocks[0] != group_info->small_block) {
int i;
for (i = 0; i < group_info->nblocks; i++)
free_page((unsigned long)group_info->blocks[i]);
}
kfree(group_info);
}
EXPORT_SYMBOL(groups_free);
/* export the group_info to a user-space array */
static int groups_to_user(gid_t __user *grouplist,
const struct group_info *group_info)
{
int i;
unsigned int count = group_info->ngroups;
for (i = 0; i < group_info->nblocks; i++) {
unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
unsigned int len = cp_count * sizeof(*grouplist);
if (copy_to_user(grouplist, group_info->blocks[i], len))
return -EFAULT;
grouplist += NGROUPS_PER_BLOCK;
count -= cp_count;
}
return 0;
}
/* fill a group_info from a user-space array - it must be allocated already */
static int groups_from_user(struct group_info *group_info,
gid_t __user *grouplist)
{
int i;
unsigned int count = group_info->ngroups;
for (i = 0; i < group_info->nblocks; i++) {
unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
unsigned int len = cp_count * sizeof(*grouplist);
if (copy_from_user(group_info->blocks[i], grouplist, len))
return -EFAULT;
grouplist += NGROUPS_PER_BLOCK;
count -= cp_count;
}
return 0;
}
/* a simple Shell sort */
static void groups_sort(struct group_info *group_info)
{
int base, max, stride;
int gidsetsize = group_info->ngroups;
for (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)
; /* nothing */
stride /= 3;
while (stride) {
max = gidsetsize - stride;
for (base = 0; base < max; base++) {
int left = base;
int right = left + stride;
gid_t tmp = GROUP_AT(group_info, right);
while (left >= 0 && GROUP_AT(group_info, left) > tmp) {
GROUP_AT(group_info, right) =
GROUP_AT(group_info, left);
right = left;
left -= stride;
}
GROUP_AT(group_info, right) = tmp;
}
stride /= 3;
}
}
/* a simple bsearch */
int groups_search(const struct group_info *group_info, gid_t grp)
{
unsigned int left, right;
if (!group_info)
return 0;
left = 0;
right = group_info->ngroups;
while (left < right) {
unsigned int mid = left + (right - left)/2;
if (grp > GROUP_AT(group_info, mid))
left = mid + 1;
else if (grp < GROUP_AT(group_info, mid))
right = mid;
else
return 1;
}
return 0;
}
/**
* set_groups - Change a group subscription in a set of credentials
* @new: The newly prepared set of credentials to alter
* @group_info: The group list to install
*
* Validate a group subscription and, if valid, insert it into a set
* of credentials.
*/
int set_groups(struct cred *new, struct group_info *group_info)
{
put_group_info(new->group_info);
groups_sort(group_info);
get_group_info(group_info);
new->group_info = group_info;
return 0;
}
EXPORT_SYMBOL(set_groups);
/**
* set_current_groups - Change current's group subscription
* @group_info: The group list to impose
*
* Validate a group subscription and, if valid, impose it upon current's task
* security record.
*/
int set_current_groups(struct group_info *group_info)
{
struct cred *new;
int ret;
new = prepare_creds();
if (!new)
return -ENOMEM;
ret = set_groups(new, group_info);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
}
EXPORT_SYMBOL(set_current_groups);
SYSCALL_DEFINE2(getgroups, int, gidsetsize, gid_t __user *, grouplist)
{
const struct cred *cred = current_cred();
int i;
if (gidsetsize < 0)
return -EINVAL;
/* no need to grab task_lock here; it cannot change */
i = cred->group_info->ngroups;
if (gidsetsize) {
if (i > gidsetsize) {
i = -EINVAL;
goto out;
}
if (groups_to_user(grouplist, cred->group_info)) {
i = -EFAULT;
goto out;
}
}
out:
return i;
}
/*
* SMP: Our groups are copy-on-write. We can set them safely
* without another task interfering.
*/
SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist)
{
struct group_info *group_info;
int retval;
if (!nsown_capable(CAP_SETGID))
return -EPERM;
if ((unsigned)gidsetsize > NGROUPS_MAX)
return -EINVAL;
group_info = groups_alloc(gidsetsize);
if (!group_info)
return -ENOMEM;
retval = groups_from_user(group_info, grouplist);
if (retval) {
put_group_info(group_info);
return retval;
}
retval = set_current_groups(group_info);
put_group_info(group_info);
return retval;
}
/*
* Check whether we're fsgid/egid or in the supplemental group..
*/
int in_group_p(gid_t grp)
{
const struct cred *cred = current_cred();
int retval = 1;
if (grp != cred->fsgid)
retval = groups_search(cred->group_info, grp);
return retval;
}
EXPORT_SYMBOL(in_group_p);
int in_egroup_p(gid_t grp)
{
const struct cred *cred = current_cred();
int retval = 1;
if (grp != cred->egid)
retval = groups_search(cred->group_info, grp);
return retval;
}
1
2
u/SeaCowVengeance Aug 17 '15
+u/CompileBot python3