mirror of https://github.com/dirtbags/moth.git
Start to add in tanks
This commit is contained in:
parent
9e8f0b39ed
commit
b563456fda
|
@ -4,3 +4,6 @@
|
||||||
*.o
|
*.o
|
||||||
bin/
|
bin/
|
||||||
build/
|
build/
|
||||||
|
cache/
|
||||||
|
target/
|
||||||
|
|
||||||
|
|
16
Makefile
16
Makefile
|
@ -1,6 +1,22 @@
|
||||||
|
# Scratch directory for building extrenal sources
|
||||||
BUILD = build
|
BUILD = build
|
||||||
|
|
||||||
|
# Root to install things before they're packaged
|
||||||
|
TARGET = target
|
||||||
|
|
||||||
|
# Downloaded source files go here
|
||||||
|
CACHE = cache
|
||||||
|
|
||||||
|
# The end result
|
||||||
BIN = bin
|
BIN = bin
|
||||||
|
|
||||||
|
|
||||||
all: packages
|
all: packages
|
||||||
|
|
||||||
|
clean: packages-clean
|
||||||
|
rm -rf $(BUILD) $(TARGET) $(BIN)
|
||||||
|
|
||||||
|
scrub: clean
|
||||||
|
rm -rf $(CACHE)
|
||||||
|
|
||||||
include packages/packages.mk
|
include packages/packages.mk
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
LOGGER_PKGDIR = $(BUILD)/logger
|
LOGGER_PKGDIR = $(TARGET)/logger
|
||||||
|
|
||||||
logger-install: logger-build
|
logger-install: logger-build
|
||||||
mkdir -p $(LOGGER_PKGDIR)
|
mkdir -p $(LOGGER_PKGDIR)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
MCP_PKGDIR = $(BUILD)/mcp
|
MCP_PKGDIR = $(TARGET)/mcp
|
||||||
|
|
||||||
mcp-install: mcp-build
|
mcp-install: mcp-build
|
||||||
mkdir -p $(MCP_PKGDIR)
|
mkdir -p $(MCP_PKGDIR)
|
||||||
|
|
|
@ -2,6 +2,14 @@
|
||||||
|
|
||||||
exec 2>&1
|
exec 2>&1
|
||||||
|
|
||||||
|
DB=/var/lib/ctf/tokens.db
|
||||||
|
|
||||||
|
if [ ! -f $DB ]; do
|
||||||
|
# Append any package-provided tokens
|
||||||
|
cat /opt/*/tokens >$DB 2>/dev/null
|
||||||
|
chown ctf $DB
|
||||||
|
fi
|
||||||
|
|
||||||
for fn in /var/lib/ctf/tokens.db /var/lib/ctf/claim.db; do
|
for fn in /var/lib/ctf/tokens.db /var/lib/ctf/claim.db; do
|
||||||
touch $fn
|
touch $fn
|
||||||
chown ctf $fn
|
chown ctf $fn
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
CFLAGS = -Wall -Werror
|
CFLAGS = -Wall -Werror
|
||||||
TARGETS = in.tokend tokencli claim.cgi
|
TARGETS = in.tokend tokencli claim.cgi
|
||||||
TARGETS += puzzler.cgi puzzles.cgi
|
TARGETS += puzzler.cgi puzzles.cgi
|
||||||
TARGETS += pointscli
|
TARGETS += pointscli mktoken
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ build: $(TARGETS)
|
||||||
in.tokend: in.tokend.o arc4.o common.o
|
in.tokend: in.tokend.o arc4.o common.o
|
||||||
tokencli: tokencli.o arc4.o
|
tokencli: tokencli.o arc4.o
|
||||||
pointscli: pointscli.o common.o
|
pointscli: pointscli.o common.o
|
||||||
|
mktoken: mktoken.o common.o
|
||||||
|
|
||||||
puzzles.cgi: puzzles.cgi.o common.o
|
puzzles.cgi: puzzles.cgi.o common.o
|
||||||
claim.cgi: claim.cgi.o common.o
|
claim.cgi: claim.cgi.o common.o
|
||||||
|
|
|
@ -524,3 +524,56 @@ award_and_log_uniquely(char const *team,
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Compute bubble babble for input buffer.
|
||||||
|
*
|
||||||
|
* The generated output will be of length 6*((inlen/2)+1), including the
|
||||||
|
* trailing NULL.
|
||||||
|
*
|
||||||
|
* Test vectors:
|
||||||
|
* `' (empty string) `xexax'
|
||||||
|
* `1234567890' `xesef-disof-gytuf-katof-movif-baxux'
|
||||||
|
* `Pineapple' `xigak-nyryk-humil-bosek-sonax'
|
||||||
|
*/
|
||||||
|
static char const consonants[] = "bcdfghklmnprstvz";
|
||||||
|
static char const vowels[] = "aeiouy";
|
||||||
|
|
||||||
|
void
|
||||||
|
bubblebabble(unsigned char *out,
|
||||||
|
unsigned char const *in,
|
||||||
|
const size_t inlen)
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
int seed = 1;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
out[pos++] = 'x';
|
||||||
|
while (1) {
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
|
if (i == inlen) {
|
||||||
|
out[pos++] = vowels[seed % 6];
|
||||||
|
out[pos++] = 'x';
|
||||||
|
out[pos++] = vowels[seed / 6];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
c = in[i++];
|
||||||
|
out[pos++] = vowels[(((c >> 6) & 3) + seed) % 6];
|
||||||
|
out[pos++] = consonants[(c >> 2) & 15];
|
||||||
|
out[pos++] = vowels[((c & 3) + (seed / 6)) % 6];
|
||||||
|
if (i == inlen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
seed = ((seed * 5) + (c * 7) + in[i]) % 36;
|
||||||
|
|
||||||
|
c = in[i++];
|
||||||
|
out[pos++] = consonants[(c >> 4) & 15];
|
||||||
|
out[pos++] = '-';
|
||||||
|
out[pos++] = consonants[c & 15];
|
||||||
|
}
|
||||||
|
|
||||||
|
out[pos++] = 'x';
|
||||||
|
out[pos] = '\0';
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#define TEAM_MAX 40
|
#define TEAM_MAX 40
|
||||||
#define CAT_MAX 40
|
#define CAT_MAX 40
|
||||||
#define TOKEN_MAX 80
|
#define TOKEN_MAX 80
|
||||||
|
#define itokenlen 5
|
||||||
|
|
||||||
|
#define bubblebabble_len(n) (6*(((n)/2)+1))
|
||||||
|
|
||||||
int cgi_init(char *global_argv[]);
|
int cgi_init(char *global_argv[]);
|
||||||
size_t cgi_item(char *str, size_t maxlen);
|
size_t cgi_item(char *str, size_t maxlen);
|
||||||
|
@ -31,5 +33,8 @@ void award_and_log_uniquely(char const *team,
|
||||||
long points,
|
long points,
|
||||||
char const *logfile,
|
char const *logfile,
|
||||||
char const *line);
|
char const *line);
|
||||||
|
void bubblebabble(unsigned char *out,
|
||||||
|
unsigned char const *in,
|
||||||
|
const size_t inlen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,62 +13,6 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "arc4.h"
|
#include "arc4.h"
|
||||||
|
|
||||||
#define itokenlen 5
|
|
||||||
|
|
||||||
char const consonants[] = "bcdfghklmnprstvz";
|
|
||||||
char const vowels[] = "aeiouy";
|
|
||||||
|
|
||||||
#define bubblebabble_len(n) (6*(((n)/2)+1))
|
|
||||||
|
|
||||||
/** Compute bubble babble for input buffer.
|
|
||||||
*
|
|
||||||
* The generated output will be of length 6*((inlen/2)+1), including the
|
|
||||||
* trailing NULL.
|
|
||||||
*
|
|
||||||
* Test vectors:
|
|
||||||
* `' (empty string) `xexax'
|
|
||||||
* `1234567890' `xesef-disof-gytuf-katof-movif-baxux'
|
|
||||||
* `Pineapple' `xigak-nyryk-humil-bosek-sonax'
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
bubblebabble(unsigned char *out,
|
|
||||||
unsigned char const *in,
|
|
||||||
const size_t inlen)
|
|
||||||
{
|
|
||||||
size_t pos = 0;
|
|
||||||
int seed = 1;
|
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
out[pos++] = 'x';
|
|
||||||
while (1) {
|
|
||||||
unsigned char c;
|
|
||||||
|
|
||||||
if (i == inlen) {
|
|
||||||
out[pos++] = vowels[seed % 6];
|
|
||||||
out[pos++] = 'x';
|
|
||||||
out[pos++] = vowels[seed / 6];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = in[i++];
|
|
||||||
out[pos++] = vowels[(((c >> 6) & 3) + seed) % 6];
|
|
||||||
out[pos++] = consonants[(c >> 2) & 15];
|
|
||||||
out[pos++] = vowels[((c & 3) + (seed / 6)) % 6];
|
|
||||||
if (i == inlen) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
seed = ((seed * 5) + (c * 7) + in[i]) % 36;
|
|
||||||
|
|
||||||
c = in[i++];
|
|
||||||
out[pos++] = consonants[(c >> 4) & 15];
|
|
||||||
out[pos++] = '-';
|
|
||||||
out[pos++] = consonants[c & 15];
|
|
||||||
}
|
|
||||||
|
|
||||||
out[pos++] = 'x';
|
|
||||||
out[pos] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sysexits.h>
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (2 != argc) {
|
||||||
|
fprintf(stderr, "Usage: %s CATEGORY\n", argv[0]);
|
||||||
|
return EX_USAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the token. */
|
||||||
|
{
|
||||||
|
unsigned char crap[itokenlen];
|
||||||
|
unsigned char digest[bubblebabble_len(itokenlen)];
|
||||||
|
|
||||||
|
urandom((char *)crap, sizeof(crap));
|
||||||
|
|
||||||
|
/* Digest some random junk. */
|
||||||
|
bubblebabble(digest, (unsigned char *)&crap, itokenlen);
|
||||||
|
|
||||||
|
/* Append digest to category name. */
|
||||||
|
printf("%s:%s\n", argv[1], digest);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
OCTOPUS_PKGDIR = $(BUILD)/octopus
|
OCTOPUS_PKGDIR = $(TARGET)/octopus
|
||||||
|
|
||||||
octopus-install: octopus-build
|
octopus-install: octopus-build
|
||||||
mkdir -p $(OCTOPUS_PKGDIR)/bin/
|
mkdir -p $(OCTOPUS_PKGDIR)/bin/
|
||||||
|
|
|
@ -9,12 +9,12 @@ define STANDARD_PUZZLE
|
||||||
t=$(strip $1)
|
t=$(strip $1)
|
||||||
$t-install: $t-stdinstall
|
$t-install: $t-stdinstall
|
||||||
$t-stdinstall:
|
$t-stdinstall:
|
||||||
mkdir -p $(BUILD)/$t
|
mkdir -p $(TARGET)/$t
|
||||||
./mkpuzzles packages/$t $(BUILD)/$t
|
./mkpuzzles packages/$t $(TARGET)/$t
|
||||||
|
|
||||||
$t-clean: $t-stdclean
|
$t-clean: $t-stdclean
|
||||||
$t-stdclean:
|
$t-stdclean:
|
||||||
rm -rf $(BUILD)/$t $(BIN)/$t.pkg
|
rm -rf $(TARGET)/$t $(BIN)/$t.pkg
|
||||||
|
|
||||||
PACKAGES += $t
|
PACKAGES += $t
|
||||||
endef
|
endef
|
||||||
|
@ -26,10 +26,10 @@ $(foreach p, $(PACKAGES), $(eval $p: $(BIN)/$p.pkg))
|
||||||
|
|
||||||
packages: $(patsubst %, $(BIN)/%.pkg, $(PACKAGES))
|
packages: $(patsubst %, $(BIN)/%.pkg, $(PACKAGES))
|
||||||
|
|
||||||
install: $(addsuffix -install, $(PACKAGES))
|
packages-install: $(addsuffix -install, $(PACKAGES))
|
||||||
|
|
||||||
clean: $(addsuffix -clean, $(PACKAGES))
|
packages-clean: $(addsuffix -clean, $(PACKAGES))
|
||||||
rm -rf $(BUILD) $(BIN)
|
rm -rf $(TARGET) $(BIN)
|
||||||
|
|
||||||
$(foreach p, $(PACKAGES), $(eval $p-clean: $p-pkgclean))
|
$(foreach p, $(PACKAGES), $(eval $p-clean: $p-pkgclean))
|
||||||
%-pkgclean:
|
%-pkgclean:
|
||||||
|
@ -37,4 +37,4 @@ $(foreach p, $(PACKAGES), $(eval $p-clean: $p-pkgclean))
|
||||||
|
|
||||||
$(BIN)/%.pkg: %-install
|
$(BIN)/%.pkg: %-install
|
||||||
@ mkdir -p $(@D)
|
@ mkdir -p $(@D)
|
||||||
mksquashfs $(BUILD)/$* $@ -all-root -noappend -no-progress
|
mksquashfs $(TARGET)/$* $@ -all-root -noappend -no-progress
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
PRINTF_PKGDIR = $(BUILD)/printf
|
PRINTF_PKGDIR = $(TARGET)/printf
|
||||||
|
|
||||||
printf-install: printf-build
|
printf-install: printf-build
|
||||||
mkdir -p $(PRINTF_PKGDIR)
|
mkdir -p $(PRINTF_PKGDIR)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
PWNABLES_PKGDIR = $(BUILD)/pwnables
|
PWNABLES_PKGDIR = $(TARGET)/pwnables
|
||||||
|
|
||||||
pwnables-install: pwnables-build
|
pwnables-install: pwnables-build
|
||||||
mkdir -p $(PWNABLES_PKGDIR)
|
mkdir -p $(PWNABLES_PKGDIR)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
TANKS_PKGDIR = $(TARGET)/tanks
|
||||||
|
TANKS_BUILDDIR = $(BUILD)/tanks
|
||||||
|
TANKS_TAR = $(CACHE)/tanks.tar.gz
|
||||||
|
TANKS_URL = "http://woozle.org/~neale/gitweb.cgi?p=ctanks;a=snapshot;h=master;sf=tgz"
|
||||||
|
|
||||||
|
$(TANKS_TAR):
|
||||||
|
@ mkdir -p $(@D)
|
||||||
|
wget -O $@ $(TANKS_URL)
|
||||||
|
|
||||||
|
tanks-source: $(TANKS_BUILDDIR)/ctanks
|
||||||
|
$(TANKS_BUILDDIR)/ctanks: $(TANKS_TAR)
|
||||||
|
mkdir -p $(TANKS_BUILDDIR)
|
||||||
|
zcat $(TANKS_TAR) | (cd $(TANKS_BUILDDIR) && tar xf -)
|
||||||
|
|
||||||
|
tanks-build: tanks-source
|
||||||
|
$(MAKE) -C $(TANKS_BUILDDIR)/ctanks
|
||||||
|
|
||||||
|
tanks-install: tanks-build
|
||||||
|
|
||||||
|
tanks-clean:
|
||||||
|
rm -f $(TANKS_BUILDDIR)
|
|
@ -1,4 +1,4 @@
|
||||||
TOKENS_PKGDIR = $(BUILD)/tokens
|
TOKENS_PKGDIR = $(TARGET)/tokens
|
||||||
|
|
||||||
tokens-install: tokens-build
|
tokens-install: tokens-build
|
||||||
mkdir -p $(TOKENS_PKGDIR)/bin/
|
mkdir -p $(TOKENS_PKGDIR)/bin/
|
||||||
|
|
Loading…
Reference in New Issue