Redshirt2 decryption!

Anything and everything

Moderators: jelco, bert_the_turtle, Chris

rf
level0
Posts: 9
Joined: Fri Apr 01, 2005 10:52 am
Location: Surrey
Contact:

Postby rf » Wed Apr 27, 2005 6:40 pm

Please dont flame me or anything, but... is this stuff used to mod darwinia (edit levels, edit how far you have got etc...) or not?

rf

edit: typos
User avatar
Miah
level5
level5
Posts: 3155
Joined: Mon Oct 13, 2003 7:28 pm
Contact:

Postby Miah » Wed Apr 27, 2005 7:21 pm

rf wrote:(edit levels, edit how far you have got etc...) or not?

Yes to both, but I would hardly call that "modding" of Darwinia
eternalbeans
level1
level1
Posts: 11
Joined: Sun May 01, 2005 2:27 pm

Postby eternalbeans » Sun May 01, 2005 6:58 pm

Samwise415 wrote:END.
USER.


I'm not sure if I can make it any more clear. :roll:

It looks like this didn't get answered yet, but I apologize if I am being redundant. So for you non-programmers, here is how to compile.

I don't know how to use a Mac and thus I don't know any specifics. First, install the dev tools. But what you will need to do is to cut and paste the code into a plain text (.txt) file and rename it to file.cpp (no txt or anything at the end). Don't use a word processor for this, just a simple text editor. Then, on the command line type:

Code: Select all

cd directory/where/cpp/file/is
g++ file.cpp -o redshirt

You can now use it based on the usage instructions. Just type it in the command windows.

For windows users:
First download and install cygwin from cygwin.org. Make sure you install gcc and c++ support for gcc (called either g++ in the setup wizard or something like gcc-c++; not sure which). Use notepad and paste the code into it. Enter the save file dialog. Navigate to the c drive and type in for filename "file.cpp" (WITH the quotes). Now run cygwin and type:

Code: Select all

cd /cygdrive/c
g++ file.cpp -o redshirt

You can now type in the commands to use the program based on the usage instructions.

Hope this helps,
eternalbeans
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Sun May 01, 2005 10:02 pm

Thank you, eternalbeans. That helps greatly.

xander
webmob
level0
Posts: 9
Joined: Tue May 03, 2005 6:11 pm
Location: Guilford,England
Contact:

Postby webmob » Wed May 25, 2005 7:34 pm

can anyone help i use the file in any of the decryption programs and all that comes up is :
[size=7]+JwYjqiq`\{<"\,W\cn_wftkaW
? 2q <0D"j uWyCinW V&\!d)Q^gt[
, :=?/&Y&J8V U;E3F:=?/&Y&J8V U;E3F:=?/&Y&J8V U;E3F:=?/&Y&J8V U;E3F:=
3 " V}YlnzQ|`wn7qxv `^)U
? , 'D)]oW{aep ]5] zd-V"mvUp^rfWW{Uv]~Uyrm$}ut
5 # V}Yl^)Q-_qdvbnv ]5] zd-V"mvUllnvSR+Vri.B}liXub.vj]
P y z\*B cv[{^tqdv1a" h#V,gwdhdepW[}]|mxH'_jbn+tzf
} M VnkxP"lm$}ut o[\0R|ixP"lmUnkad^NJ]&o
O s &_xU#^rf ]5] zd-V"mvU#^rfQN+Jog~p-v|
- : jarQN0L|m.p-v| crpskaW{N!^)U-]millrv ]5]
E + 'D)]xW}qet`H~^sa~UFr!j wrln
+ x *J}Z{L(qx^noe0fa1 W#g&
sH . uWy\rgUN&_rmGW1r vkui
13 " V}Ylo~P)jm$}ut pgU)
5|^zW"mvihBnf6N#R{d.L(l

Jkridk`P0H`ozU-Bm\rkiv[X+
k V_ .HykQZ ulcKV ]6Yr g#Q$ mvbrke
% /&Y&J8V U;E3F:=?/&Y&J8V U;E3F:=?/&Y&J8V
uN 0 @ & 9 .
23 $ ! L x >
+ KwM / :- 9 -
3 4'} M } = +
O t I 1 8 &
:0 2 3 % x L
" > , K{ H .
9& ; . 2; " x
N z ? . L s
K 0 : ) 9 .
8 4 $ yM { >
4 K t M . 8
'9 / 2 7 " x
My ? - N r H
/: ( ; 2 0 2
" zQ} @ ,J t I
0 : ) :. 6 3
% z O y> / J
v J 1 9' > .
59 $ { O }E ,
Nz J 1 ; +@ .
5; $ { O x >
1I t K 1 =/ :
31 4 % { Rz >
1K t K 1 >' :
33 4 % } L x
C/ K u M . 8
-B / 3 7 " x
Tx > . N r H
6= & < 01 2 #
!R z @ 0 I r
P5 : ) > - 0
:* z O } = +
Q{ J 1 = & 9
60 4 % } L x
F, K u M . 8
/; / 3 7 " x
U{ ? . N r H
7< ( < 2 0 2
*z N { ?4 I s
P1 : ) ;6 0 3
*| N { ?4 I s
H 0 < '= - 1
4% zQ} A ,J x H
2A & = .1 5 #
}S y A 0 I r
M/ : * < 31 3
'z N | @ + J
wM 0 < ) >6 1
7+ z P { = ,
Os J 2 ; & :
32 4'} P y> 0 J
xK / < + 9 -
56 $ | Q x =
1M t L 3 8 &
?2 2 6 ' x L
~D - M w H .
>. ; 1 5 2 "
~U z A 0 I r
O. : * > - 0
9( z P } = +
Or J 2 9' @ .
68 $ | Q x =
0I t L 0A & :
23 4 & zU x >
3R t M /9 , :
60 2 ' zO A ,
Rt J3= + :. 3 3
" z Q } = +
J s M 3 8 &
< / 5 5 " y
P z B . L s
P 0 = ) B .
9 4 ' { T y
>+ K w M . 8
': / 5 7 " x
Pz = 0 Kv H .
<* 9 2 26 " x
P{ = 0 Kv H .
<+ 9 2 26 " x
M{ ? 0 N r H
39 ( > 2 0 2
'z N } B + I
wM 0 = + 9 -
59 $ } Q x =
4M t M /9 * :
66 4 ' } L x
F2 K w J7 8 '
:-8 4 ' zU x >
,K t M 0A & :
- 0 8 $} L x
A + O uI . 8
+ ;25 8 #y P x
C , O w H .
? (>2 6 3# } M
! > 1 N r H
7 : , < .0 3
#x N ~ @ + J
sI / > ) 9 -
3 4'} R y> 4 I
xI / > + 9 -
93 # ~ Q x =
4K t N 3 8 &
B0 2 8 ' x L
"A , O w H .
9 ' ? .1 3" x
Q} > 1 N r H
3< ' ? 2 0 2
+! M ~ >, L s
Q7 9 , > - 0
3#x M ~ >, Q r
I/9 ' ? 2 0 2
#xM y C .J r H
3; ' ? /9 2 "
z M ~ ?4 I r
I . ? ): - 0
4 # O x =
. J y K . 8
* : 4 5 2 "
} M B + I
x I 5 = & 9
4 2 9 ' x L
! ? 2 L r H
7 9 - < - 0
3" y S { = +
Js J 5 ; & 9
.2 4 ) } L x
>. J y M . 8
(: /57 ) yM | >
-K s O 3 8 &
:1 2 9 $" L x
>0 K y J7 8 &
: . 8 6% x L
z ? 3 Js N .
= ' A 0 0 2
# M ! B + I
sP / @ + 9 -
9 3 * } L x
>, J z K . 8
(9 . 8 7 " x
Nz > 3 N r H
1? ' A 2 0 2
'x M ! B + I
wI / @ + 9 -
58 # ! Q x =
0P s P 3 8 &
:0 1 : $" L x
A4 J z J7 8 &
>/ 1 : $" L x
B0 J z J7 8 &
>5 1 : $" L x
> -Nw Q /9 . 9
/ 27' " My >+ I
r I 7 = & 9
0 1 ; ' x L
| > 4 N r H
3 9 / < - 0
9 # " O x =
3 J { K . 8
'9 . 9 5 " x
My > 4 L r H
/= ' B 2 0 2
#~ M " B + I
sQ / A + 9 -
22 # " Q x =
4I s Q 1A & 9
50 3 + { L x
E, J { K . 8
.@ . 9 5 " x
T" > 4 N r H
79 ' B 2 0 2
+{ M " B + I
{L / A + 9 -
97 # " Q x =
4O s Q 3 8 &
B4 1 ; ' x L
y=3 J { K . 8
'96 1 ; % x L
y>+ J { K . 8
':. 1 ; % x L
y>- J { K . 8
':0 1 ; ' x L
y>2 J { I/ 9' 9
.1: # " Q x =
,J{ I 7 9' ? -
14" y U } = +
JvK 0=+ :- 13 ( x
M|A -Nw I. 9' A -
16' zQ} >+ Js Q .
9 ( :- 38 " x
MzB , Jr M . 8
';3 1 3" { L x
>-P s I. ; & 9
.2: # yL { = +
JtQ / 9& < - 0
3%x M y= . I r
I19 ' :- 3 2 "
yOz > ,I w H .
9)< . 12 ' x L
y@/ J sH 3 8 &
:05 3 #x Q x =
,Lx I /8 + 9 -
15) y Mx B + I
sK7 9 '9 2 0 2
#|L y >+ N r H
/=+ : .0 7 " x
M}E , Jr M . 8
'<5 1 3" zU x =
,Ny I /8 (B - 0
2 # yM y> 4 I
v I /9 ) 9 -
5 3 #y O x =
1 J sI 1 8 &
@ . 13 % x L
! > ,J w H .
A ' :. 5 2 "
yL y >, N r H
/9 ' :. 5 2 "
yO y >, N r H
/< ' :. 3 2 "
zM y >, L r H
0: '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iq` ;2W`^,L)r "W{a_g`MJ]&o
^Q|
C~[wq Bw[U!R{bhQ%gv[ CmavfN/Wl]/I~cz": ?uk^M&WtJ(O"lm 0{bcg[_"[9,
ZF-gwd [rnUU[&Y" h/V"a=$}ut
G`M
a_ri. 1(rQdUlccfR,W Op#O|gv]Xklk`N VYno.H+lgX~cfgdtM +#d&G"loEwiipW #/Np`#Y}p4'
J`tkaW oN"H#V,gwd kfoubQ"[r h#V,gwdh_iqeY%N `xU}aif}rrg ]5]
N^.L(l ZkwPct[Y1 Y `{L(qx^noe
G`M
a_ri. %.gtZrkgQ`U&Wr 5{L(qx^noe.+x
]L"d)Q jsvIloirf K&X!k"H+cghnadgSM
aWq
@0H'r Ve}FnNaL}]vj( %.gtZrkgQ`U&Wr 5{L(qx^noe.+x ^^vg}L'eWdufng ,K&X!k"H+c4':4
AefR,W ``.0"q{_xk tg_Y)N zd-V"mvU}bmr^N{L#o-F}lm$}ut
CU]&X{ M/Qkaz_yq bka\-Qrm~B}ll
;wa
ExWW1 +#d&G"loEwiipW #1Nzk&HD5> 8~flf[W$8{g#Q} 8|[vmlg} S +#d&G"loEwiipW #1Nzk&HD69
7lqiq` ;2W`^,L)r oWvboxW[
aWq
@0H'r Ve}FnNaL}]vj( %.gtZrkgQ`U&Wr 5.H&nt[546 DgR)Mvi!2'jqdn 7tg_Y)N92P %.gtZrkgQ`U&Wr 5.H&nt[551
CU]&X{ M/Qkaz_yq gc_N,_rmGW1r
Mdm
Bvg`]0HRi}'}dqdrqiq`
[/size]
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Thu May 26, 2005 2:46 am

Okay, I assume you know this, but what you posted does not decrypt to anything useful. It also does not re-encrypt into anthing that makes sense to me. Could you post the original file that you are trying to decrypt, please?

xander
webmob
level0
Posts: 9
Joined: Tue May 03, 2005 6:11 pm
Location: Guilford,England
Contact:

Postby webmob » Thu May 26, 2005 7:26 am

it is my game.txt file and this is the original (without red shirt 2 at start)
Sxdlvntq%(_8w.vclojykynr
K U( W2c)s vb{Hnqh ~27+pepuf
. ?BB@NeI`SX?\DF>H?BB@NeI`SX?\DF>H?BB@NeI`SX?\DF>H?BB@NeI`SX?\DF>H?B
6 3 ~*|#*|p$ixy9v}y q'5x
U G )c0fpb}fjs1&A! 1/u)vw`rcwih(x-x!t!{n/zy
8 4 ~*|#y+p4hroxgsy1&A! 1/u)vw`nqsydz7y)%0a%ujcwg3y{&
\ = 1w,a'lwf}cytu?=%8 $%u3pxojijsh$*!3)zg.hkmp0y}w
F Y y%'zo)un/zy rl%<u3%zo)un`ppfgovV!<+
Q 3 -hy`%cwi1&A! 1/u)vw`%cwibv7m&#!04}
8 < ofubv<o3)004} ntuxnr(q7y+t4fntnqwy1&A!
[ F )c0fybvjwqp+"*|!tM{"u ywqq
< A 6m4u}k/zyiptj3w*= z9#(
3O 7 vb{awjfv2#))Iv8{ wvwn
66 3 ~*|#+!o0sn/zy sx}5
X3y|v)vwtjGsiGv/u20k/u

Kvtninqx<kv+|t4Kngtpnyl!7
/ lz 0g!tRe wqhNg &B|) #%p+ vwmtpj
( @NeI`SX?\DF>H?BB@NeI`SX?\DF>H?BB@NeI`SX
5U 9 A 1 ; 3
76 5 I X < T
F M7T 8 ;8 ; 2
8 78F Y A S F
Q 4 P : 9 1
<5 7 6 6 A X
E T G M; O 7
:1 = 3 7> 3 A
Z > U I N 3
R 9 ; 4 ; 3
= 7 5 BY ? T
O M 4 T 7 9
2; 4 7 : 3 A
Y= U H P 2 O
8; 3 = 7 5 5
3 C]A V GL 4 P
9 ; 4 <3 ; 6
6 C [ =T J L
6 Q : :2 @ 3
:< 5 D [ A[ G
P: Q : < 6B 3
:> 5 D [ < T
LK 4 R : >: <
86 7 6 D ^> T
LM 4 R : ?2 <
88 7 6 F X <
YJ M 5 T 7 9
8D 4 8 : 3 A
`< T I P 2 O
?> 1 > 56 5 4
I^ > V K K 2
W> ; 4 @ 2 5
=;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 4< 2 5
7 4 H [ < S
I L 9 R 7 9
5 < 9 : 5 3
F Y C X F K
8 P > > 1 ;
9 7 < 8 A X
D U M N 2 O
@ : 8 > 2 5
63 B _ ? S F
L3 Q > < 1 ;
37 7 : F X <
TI L 9 T 7 9
3< 4:: : BY @ T
HM 3 V < 9 1
<6 7 < 5J X <
TK M 9 Q@ 9 1
< 3 = 96 A X
> U N L3 U 7
> 2 C 5 5 5
4H Y D X F K
3W 8 A 6 ; 2
> 6 ; F X <
TG L : R 7 9
3; 3 = : 3 A
Z> T N P 2 O
:@ 2 C 7 5 5
8A Y D X F K
7P 8 A 6 ; 2
:; 4 I ] < S
KR 3 W < 9 1
<5 6 = 5J X <
WO L : Q@ 9 1
@4 6 = 5J X <
XK L : Q@ 9 1
@: 6 = 5J X <
T HP7 X 8: 9 ;
4 7:8 J Y= TF K
2 P @ > 1 ;
5 6 > 8 A X
@ T O P 2 O
< : : > 2 5
< 4 J [ < S
N L ; R 7 9
2; 3 > 8 3 A
Y= T O N 2 O
8> 2 D 7 5 5
4G Y E X F K
3X 8 B 6 ; 2
75 4 J ] < S
OK 3 X :B 1 ;
:5 6 < D X <
[G L ; R 7 9
9B 3 > 8 3 A
`E T O P 2 O
@: 2 D 7 5 5
<D Y E X F K
;S 8 B 6 ; 2
>: 4 J ] < S
OQ 3 X < 9 1
D9 6 > 8 A X
=SN L ; R 7 9
2;; 6 > 6 A X
=TF L ; R 7 9
2<3 6 > 6 A X
=TH L ; R 7 9
2<5 6 > 8 A X
=TM L ; P8 :2 ;
36= 4 J ] < S
GL; P @ :2 A 2
673 B a A S F
L6R 9>6 <2 66 9 A
Y@W HP7 P7 :2 C 2
698 C]A TF L3 X 7
: 3 <2 8; 3 A
Y>X G L2 T 7 9
2=8 6 63 D X <
THR 3 P7 < 1 ;
37= 4 BX ? S F
L4X 8 :1 > 2 5
66A Y =S I K 2
P:: 2 <2 8 5 3
B[> T GK 7 O 7
:4> 3 65 8 A X
=VJ L 3O < 9 1
<5: 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Bm6zzc2txv}0y}w
V7p
h-!p4 UxuTpQtfr=u3% ]w)smjyiTsoz7q ]0|t$3= C!kqil0[2#%p% A#b}f18 E'2x(*inuujyg ?~d$-8T X1k,krorQsql. F=w.fK8:1 Mwnqgz7sr%(k.l Czlti14AY
M'+%q. ZnuXkxxl!7 ~)y!k6l{ ntuxnr(~)y!k6l{`}ghfs&>~)D0z4
Hlutqs Xh&uu7*%q. wjugwsbs>r*{. o)z|jzpdud&=q6%zd5mof}awjfr9!9)!04}
Bnvntq c>zvy.k0{ #b}fdjquV!<+
`p$
Lfyv Gzl}-u2}jp,pwf Erfywv;z#x1h&l{-< Dznou2z+e*n)un ;}ghjl(.~OG
\e4pxo ]wsXf$2|8 $1u)j>/zy
Jqu
m#)%0 P/{RoWqhfwz8z e,%n$pwhZpqnqv b|%+0g2uhc!hkju=Y N9(f)upPynnsh K;q'{%x%y52
Leynr {q8c%u3pxo mktxsy.~) $%u3pxojdntv"1q6{zt%jjqwwj1&A!
dy0k/u [vyUhwl"= |6{}k/zyiptj
Jqu
m#)%0 D5puetplTq}2z) P}k/zyiptj1<A
io8+p q|wTntnuw s2{7'$g2lhspfijdu
mz(
[2g.{ WpKsQrt*!-&* D5puetplTq}2z) P}k/zyiptj1<A j"-#k.nXowksj =s2{7'$g2l52<9
Fhwz8z v{0O)z|jzp yjp"5q 1/u)vw`gruov(o9+/e%un/zy
Ff&2{2 h1prj{j{v gnr%9t))!a%um
Fyf
J{h= N9(f)upPynnsh K=q1'(gK>? C!kqil0[2#%p% A}fxrqj/H_ N9(f)upPynnsh K=q1'(gK?:
Bnvntq c>zvy.k0{ pbxgt{h$
mz(
[2g.{ WpKsQrt*!-&* D5puetplTq}2z) P0g-wuf79; Gxz5p-%#Q.srop <yjp"5qOMR D5puetplTq}2z) P0g-wuf7:6
Ff&2{2 h1prj{j{v lfpv8#))Iv8{
Noo
G{jq&<kh%F%mrotvntq
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Thu May 26, 2005 3:14 pm

Using the Ruby decryption tool, this is what I get:

Code: Select all

Locations_StartDefinition
# Id Avail mapFile missionFile
# ==================================================================
1 0 map_sandbox.txt null
2 1 map_garden.txt mission_garden_liberate.txt
3 1 map_containment.txt mission_containment_enable.txt
4 1 map_generator.txt mission_generator_enable.txt
5 1 map_mine.txt mission_mine_enable.txt
6 1 map_yard.txt mission_yard_enable.txt
7 1 map_escort.txt mission_escort_escort.txt
8 0 map_pattern_buffer.txt null
9 0 map_biosphere.txt null
10 0 map_receiver.txt null
11 0 map_temple.txt null
Locations_EndDefinition

Buildings_StartDefinition
# Id teamId locId type link online
# =======================================
36 2 8 0 0 1
21 2 8 0 0 1
0 255 1 27 0 0
3 255 1 5 0 0
6 2 1 3 0 0
13 2 1 3 0 0
9 1 1 29 0 0
10 2 1 29 0 0
2 2 2 3 3 1
3 2 2 3 0 1
8 2 2 11 3 1
9 2 2 5 0 0
10 2 2 5 0 0
11 2 2 5 0 0
12 2 2 5 0 0
0 255 3 11 2 1
2 2 3 11 6 1
3 2 3 11 4 1
4 2 3 11 5 1
57 2 3 3 58 1
58 2 3 3 57 1
59 2 3 3 0 1
60 2 3 3 59 1
61 2 3 3 62 1
62 2 3 3 61 1
63 2 3 5 0 0
64 2 3 5 0 0
79 2 3 5 0 0
80 1 3 5 0 0
85 0 3 31 0 1
86 2 3 5 0 0
87 2 3 5 0 0
88 2 3 5 0 0
89 2 3 5 0 0
90 2 3 5 0 0
91 2 3 5 0 0
92 2 3 5 0 0
93 2 3 5 0 0
94 2 3 5 0 0
82 2 3 29 0 1
83 2 3 29 0 1
84 2 3 29 0 1
0 2 4 14 0 1
23 255 4 11 6 0
49 0 4 11 3 1
57 1 4 5 0 0
51 2 4 3 61 1
52 2 4 3 0 1
55 2 4 3 59 1
59 2 4 3 0 1
61 2 4 3 0 1
62 255 4 11 5 1
63 1 4 5 0 0
54 2 4 5 0 0
64 2 4 5 0 0
65 2 4 5 0 0
67 2 4 5 0 0
68 2 4 5 0 0
69 2 4 5 0 0
70 2 4 5 0 0
76 2 4 5 0 0
60 2 4 11 7 1
66 2 4 5 0 0
50 2 4 29 0 1
53 2 4 29 0 1
89 2 5 11 6 1
90 0 5 23 74 1
92 255 5 11 3 1
0 2 5 5 0 0
1 1 5 5 0 0
3 2 5 3 0 1
4 2 5 3 3 1
8 2 5 3 9 1
9 2 5 3 8 1
10 2 5 5 0 0
11 2 5 5 0 0
42 0 5 24 0 0
44 0 5 24 0 0
43 0 5 24 0 0
45 0 5 24 0 0
13 2 5 5 0 0
51 2 5 5 0 0
52 2 5 5 0 0
55 2 5 5 0 0
57 2 5 5 0 0
94 2 5 11 4 1
96 2 5 5 0 0
97 2 5 29 0 1
108 2 5 29 0 1
12 2 5 29 0 1
0 0 6 25 0 0
4 0 6 31 0 0
5 255 6 11 4 0
6 1 6 5 0 0
7 255 6 11 5 1
8 1 6 5 0 0
9 2 6 3 10 1
10 2 6 3 0 1
11 1 6 3 0 0
3 255 6 11 9 0
61 1 6 5 0 0
91 1 6 5 0 0
92 2 6 5 0 0
93 2 6 5 0 0
94 1 6 5 0 0
1 1 6 11 10 0
55 1 6 5 0 0
54 1 6 5 0 0
98 1 6 11 3 1
99 1 6 5 0 0
110 1 6 11 8 0
111 1 6 5 0 0
101 1 6 31 0 0
53 1 6 29 0 0
2 1 6 29 0 0
1 0 7 31 0 0
2 1 7 3 0 0
3 1 7 3 0 0
4 1 7 5 0 0
5 1 7 5 0 0
6 1 7 5 0 0
7 2 7 5 0 0
8 2 7 3 0 0
9 1 7 3 0 0
10 1 7 3 0 0
11 2 7 3 0 0
12 2 7 5 0 0
13 1 7 5 0 0
21 255 7 11 4 1
22 1 7 5 0 0
14 2 7 29 0 0
15 2 7 29 0 0
1 1 8 43 0 0
2 2 8 11 6 0
5 1 8 3 0 0
17 1 8 5 0 0
18 1 8 5 0 0
9 1 8 5 0 0
11 1 8 3 0 0
20 1 8 5 0 0
22 1 8 5 0 0
37 1 8 5 0 0
50 1 8 5 0 0
51 1 8 5 0 0
56 1 8 5 0 0
57 1 8 5 0 0
13 1 8 29 0 0
49 1 8 29 0 0
52 1 8 29 0 0
55 1 8 29 0 0
58 1 8 29 0 0
1 255 9 11 8 0
2 255 9 11 10 0
0 1 9 5 0 0
3 1 9 5 0 0
4 1 9 5 0 0
5 1 9 3 0 0
7 1 9 3 0 0
8 1 9 3 0 0
10 1 9 3 0 0
11 1 9 3 0 0
15 1 9 5 0 0
16 1 9 5 0 0
19 1 9 5 0 0
20 1 9 5 0 0
90 1 9 39 0 0
80 1 9 3 0 0
81 1 9 3 0 0
87 1 9 3 0 0
89 1 9 5 0 0
91 1 9 5 0 0
93 1 9 5 0 0
94 1 9 5 0 0
95 1 9 5 0 0
96 1 9 5 0 0
97 1 9 5 0 0
108 1 9 3 0 0
109 1 9 3 0 0
110 1 9 3 0 0
111 1 9 3 0 0
112 1 9 3 0 0
113 1 9 5 0 0
117 1 9 11 11 0
118 1 9 5 0 0
119 1 9 11 6 0
120 1 9 5 0 0
143 255 10 11 6 0
144 255 10 11 8 0
145 255 10 11 9 0
1 2 10 36 0 0
125 1 10 5 0 0
126 1 10 3 0 0
127 1 10 3 0 0
128 1 10 3 0 0
129 1 10 3 0 0
130 1 10 3 0 0
131 1 10 3 0 0
132 1 10 5 0 0
133 1 10 5 0 0
134 1 10 5 0 0
135 1 10 5 0 0
136 1 10 5 0 0
137 1 10 5 0 0
139 1 10 5 0 0
140 1 10 5 0 0
155 1 10 5 0 0
158 1 10 5 0 0
138 1 10 29 0 0
157 1 10 29 0 0
0 1 11 11 9 0
4 1 11 3 0 0
5 1 11 3 0 0
6 1 11 3 0 0
7 1 11 3 0 0
8 1 11 5 0 0
9 1 11 5 0 0
10 1 11 5 0 0
11 1 11 5 0 0
13 1 11 5 0 0
14 1 11 3 0 0
21 1 11 3 0 0
22 1 11 5 0 0
30 1 11 5 0 0
31 1 11 5 0 0
59 1 11 5 0 0
80 1 11 3 0 0
82 1 11 5 0 0
84 1 11 5 0 0
78 1 11 29 0 0
79 1 11 29 0 0
83 1 11 29 0 0
81 1 11 47 0 0
76 1 11 47 0 0
77 1 11 47 0 0
Buildings_EndDefinition

Research_StartDefinition
Research Darwinian 0 4
Research Officer 10 3
Research Squad 0 1
Research Laser 46 2
Research Grenade 24 2
Research Rocket 0 1
Research Controller 0 0
Research AirStrike 1 1
Research Armour 0 0
Research TaskManager 1 3
Research Engineer 38 2
CurrentResearch Squad
CurrentPoints 0
Research_EndDefinition

Events_StartDefinition
Event BuildingOnline :yard,5
Action RunScript yard_progress
End
Event BuildingOnline :yard,4
Action RunScript yard_progressarmour
End
Event BuildingOnline :yard,4 BuildingOnline :yard,3 BuildingOnline :yard,1 BuildingOnline :yard,110 BuildingOnline :yard,101
Action RunScript yard_armour.txt
End
Event NotInLocation BuildingOnline :yard,4 BuildingOnline :yard,3 BuildingOnline :yard,1 BuildingOnline :yard,110 BuildingOnline :yard,101
Action SetMission receiver mission_receiver_recapture.txt
Action SetMission pattern_buffer mission_pattern_buffer_recapture.txt
Action RunScript yard_end.txt
End
Event BuildingOnline :pattern_buffer,1 BuildingOnline :receiver,1
Action RunScript music5.txt
End
Event NotInLocation BuildingOnline :pattern_buffer,1 BuildingOnline :receiver,1
Action SetMission biosphere mission_biosphere_recapture.txt
Action RunScript prebiosphere
End
Event BuildingOnline :biosphere,90
Action RunScript biosphere_reddead
End
Event NotInLocation BuildingOnline :biosphere,90 BuildingOnline :biosphere,117
Action SetMission temple mission_temple_cutscene.txt
Action RunScript biosphere_end
End
Event BuildingOnline :temple,76 BuildingOnline :temple,77 BuildingOnline :temple,81
Action RunScript gameover
End
Event NotInLocation BuildingOnline :temple,76 BuildingOnline :temple,77 BuildingOnline :temple,81
Action RunScript gameover.txt
End
Events_EndDefinition

Because of the way that you pasted the file into the forum, some of the formatting in the Events section is a bit off, though that should not effect the game, I think. If you want to keep your formatting, you should use the [code] tags. Out of curiosity, which decryption script were you using? And have you been removing 'redshirt2' from the beginning before you decrypt? A couple of the scripts expect that to be at the beginning, and will not work quite right if it is not there.

xander
webmob
level0
Posts: 9
Joined: Tue May 03, 2005 6:11 pm
Location: Guilford,England
Contact:

Postby webmob » Fri May 27, 2005 6:47 pm

thanks but its wierd i restarted my laptop and it works fine now!!
dx9s
level0
Posts: 4
Joined: Thu Jun 02, 2005 8:58 pm

Encode/Decode w/ PHP RedShirt2

Postby dx9s » Thu Jun 02, 2005 9:28 pm

First off -- kudos to Jackmn

After looking / testing the Perl code, and giving the C code a whirl (without looking a the code closely) -- the encoding works (wrong) and decoding is broken (but is closer to being correct -- as least for gcc/linux). I haven't read the entire thread, just the first page and I got to coding a solution...

The Perl code appeared to work flawlessly for decoding... And upone thinking about the process wrote (below) from scratch in PHP (I prefer) -- however I didn't use the same

if( $first_line ) {
s/^redshirt2//;
$first_line=0;
}

method... and I should attempt to improve it (perhaps), but my method is a hybrid that encodeds and decodes based on the input stream (first line) if it has "redshirt2" -or- not...

So I studied and review the process and reversed it (as best as one can given the input encoding restrictions for 'Redshirt2'), I also have some comments...

Here is the results:

doug@seet:~$ php redshirt2.php < game.txt > x
doug@seet:~$ php redshirt2.php < x > y
doug@seet:~$ diff y game.txt
doug@seet:~$ ls -la game.txt y
-rw-r--r-- 1 doug doug 13131 2005-06-02 10:33 game.txt
-rw-r--r-- 1 doug doug 13131 2005-06-02 12:54 y

They are identical!!! (game.txt is a copy of what is from the ~/.darwinia/[...] unix-style homedir save game method)

You can also chmod 555 redshirt2.php (or whatever you save the file as), and insert '#!/usr/bin/php' (or whatever you CLI PHP path is) on the first line


Code: Select all

<?php

/// written to use 4.3.11 (CLI)... not sure at what point older version stop working
/// and a STDIN/STDOUT/STDERR *hack* (php has access to them in previous versions, see code)
/// Douglas Marsh

/*
////////////////
/// Based on what I understand from the perl decode reference code (if it is close enough)
/// however expanded for support encoding and decoding of "redshirt2"
/// http://forums.introversion.co.uk/darwinia/viewtopic.php?t=1550
/// ##PHP is cross between C/C++ and Perl for the most part)!## */

if (version_compare(phpversion(),'4.3.0','<')) { // otherwise manually open/close STDIN/STDOUT/STDERR
 define('STDIN',fopen("php://stdin","r"));
 define('STDOUT',fopen("php://stout","r"));
 define('STDERR',fopen("php://sterr","r"));
 register_shutdown_function( create_function( '' , 'fclose(STDIN); fclose(STOUT); fclose(STERR); return true;' ) );
}

// $input = fgets(STDIN, 1024);

$keytable = array(
               0 => hexdec("1f"), 1 => hexdec("07"), 2 => hexdec("09"), 3 => hexdec("01"),
               4 => hexdec("0B"), 5 => hexdec("02"), 6 => hexdec("05"), 7 => hexdec("05"),
               8 => hexdec("03"), 9 => hexdec("11"), 10 => hexdec("28"), 11 => hexdec("0c"),
               12 => hexdec("23"), 13 => hexdec("16"), 14 => hexdec("1B"), 15 => hexdec("02")); // end of redshirt2 key

$input = fgets(STDIN, 10); // check input for "redshirt2" (nine characters)
// IT says 10, because when I put 9, it reads 8... not sure if this is universal  (win32/linux/mac), you might need to change this part!


/// Not exact "do loop until" redshirt2 comes into the buffer, expect first line/char to be "r"..edshirt2
/// perhaps should clean this up later, however that would change my "detect" encode/decode code below a bit

if ($input=="redshirt2" || $input=="REDSHIRT2") { // we are reading in a file to decode
  $DECODE=TRUE; $ENCODE=FALSE; $input='';
} else {   // we are encoding
  $DECODE=FALSE; $ENCODE=TRUE; echo "redshirt2";
}

/// Load input file into memory, PHP can handle large files (in the meg-o-bytes)
$buffer='';

while ( !feof(STDIN)) {
   $buffer .= $input . fgets(STDIN, 4096);
   $input = ''; // to get the input string if it header wasn't redshirt2
}

unset($input);

// Don't have access to Windows generated redshirt2 file, so not sure if \r\n (DOS) or \n ... so gonna search to see if it exist

if (strpos($buffer,"\r\n")===FALSE) { // we have UNIX \n
  $newline="\n";
} else {
  $newline="\r\n";
}

$infile = split($newline, $buffer);

$keyindex =0;

reset($infile); $SKIP_FIRST = TRUE;
while (list($ignore, $line) = each($infile)) {
  if ($SKIP_FIRST == TRUE) {
    $SKIP_FIRST = FALSE;
  }  else {
     echo $newline;
  }
  if (strlen($line)>0) { // is 1 or more characters
 
    for ($i=0; $i < strlen($line); $i++) {
      $char = ord(substr($line, $i, 1));

      if ($DECODE) {
        if ($char > 32) { // in range other wise leave spaces and below alone
          $keyindex = ($keyindex + 1 ) % 16;

          $char -= $keytable[$keyindex];
          if ($char < 32) { // must keep all "inrange" values ... in range
            $char += hexdec("5f");
          }
        } // char in range
      } // end of if DECODE

      if ($ENCODE) {
        if ($char > 32) { // in range otherwise leave all control characters/spaces alone
          $keyindex = ($keyindex + 1 ) % 16;

          if ( (($char - hexdec("5f") + $keytable[$keyindex]) > 32) &&
               (($char - hexdec("5f")) <= 32) ) { // if can roll 0x5f and keep in range
            $char -= hexdec("5f"); // then do so
          } // the intent is to "keep" printable characters for the most part (and control chars, 0-32)

          // PS doesn't handle non-printable (0x80 and above) characters well, but attempts to preserve them somewhat
          // can only encode up to 0xFF - largest key in table (0x28)
          // the reference code never mentions upper limits on encoding
          //  perhaps redshirt2 is designed for printable 7-bit ASCII (0-127)

          $char += $keytable[$keyindex];

          // the "what if" probability  has to be accounted for as the source input requirements (7-bit ASCII?)
          // is unknown... so I will just simple check for out of bounds (>255) and subtract 0x5f
          // the character will most likely end up being a printable character (<128) when it was started off
          // being 8-bit range (128-255).

          if ($char > 255) {
            $char -= hexdec("5f");
          }
        } // end of if in range
      } // end of ENCODE

      echo chr($char);

    } // for each character
   
  } // if strlen 1 or more -OR- not
}

// Hmm, this should work as expected for 7-bit characters, will try to encode 8-bit stuff but if out of bounds.... to bad

?>
dx9s
level0
Posts: 4
Joined: Thu Jun 02, 2005 8:58 pm

Update.

Postby dx9s » Thu Jun 02, 2005 11:39 pm

While the program works... and upon closer examination and "thinking" ...

and looking and the more interesting C code from Uniter...

I got the idea of making a binary safe RedShirt2, that *should* work correctly ... But need to think about it for a bit.

BTW My PHP code is not binary safe, it will destroy some of the information (due to a quick write / hack / port)...

Understand that I just got the game less that 24 hour (order it / shipped over seas / forgot about it for a while, showed up at house and a good surprise) and I am already digging into the files.. stumbled on this group. Need to play the Uplink Demo (for linux) that also came on the CD ;) (as it has to do with hacking).... which is what we are doing here!

I'll dink around a little bit more -- and make improvements (I wrote the PHP port, in perhaps an one hour)...

The whole 7-bit/8-bit thing has bugged me until I saw the code from Uniter... Thanks! completely forgot about wrapping around upon overflow in C (haven't written a line in some time now).

// C code fragment in my mind (to think about)
// perhaps "unsigned" but that should be assumed
char c =253;

// assuming a REAL 8-bit char (some compilers
// make char the same size as int 16 or 32-bits).

c++; // c=254
c++; // c=255
c++; // c=0
// [...]

--Doug
dx9s
level0
Posts: 4
Joined: Thu Jun 02, 2005 8:58 pm

Finial (cleaner/safer) PHP port of RedShirt2 (revision a)

Postby dx9s » Fri Jun 03, 2005 9:39 pm

Okay... After much deliberation... and some cleaning of the code...
and some thinking...

Here is a binary safe** "RedShirt2" (revision a)
[aka redshirt2a.php]

**= If the "source file includes" redshirt2, it will falsely detect and "decode" from that point
Sooo I put restraints that the "redshirt2" must be within ~10 bytes from the beginning of the file.
(mimicking the perl code I talked about earilier )

Results:

doug@seet:/tmp2$ cat bintest.sh
dd if=/dev/urandom of=a.in bs=1024 count=20
php redshirt2.php < a.in > a.code
php redshirt2.php < a.code > a.out
diff a.in a.out
doug@seet:/tmp2$ sh bintest.sh
20+0 records in
20+0 records out
doug@seet:/tmp2$

and the legacy test results:

doug@seet:/tmp2$ php redshirt2.php <game.txt > game.out
doug@seet:/tmp2$ php redshirt2.php <game.out > game.new
doug@seet:/tmp2$ diff game.txt game.new
doug@seet:/tmp2$

And the code:

Code: Select all

<?php

/// written to use 4.3.11 (CLI)... not sure at what point older version stop working
/// and a STDIN/STDOUT/STDERR *hack* (php has access to them in previous versions, see code)
/// Douglas Marsh

/// Changes RedShirt2.php (revision a)
/// design changes, to make binary safe and backwards compatible with 7-bit ASCII source files.

/*
////////////////
/// Based on what I understand from the perl decode reference code (if it is close enough)
/// however expanded for support encoding and decoding of "redshirt2"
/// http://forums.introversion.co.uk/darwinia/viewtopic.php?t=1550
/// ##PHP is cross between C/C++ and Perl for the most part)!## */

if (version_compare(phpversion(),'4.3.0','<')) { // otherwise manually open/close STDIN/STDOUT/STDERR
 define('STDIN',fopen("php://stdin","r"));
 define('STDOUT',fopen("php://stout","r"));
 define('STDERR',fopen("php://sterr","r"));
 register_shutdown_function(
   create_function( '' , 'fclose(STDIN); fclose(STOUT); fclose(STERR); return true;' )
 );
}

define('KEYCONST', 16); // much easier to change/alter/update
$TheKey = '1f0709010b0205050311280c23161b02';
$keytable = array();
for ($i=0;$i<KEYCONST;$i++) {
  $keytable[$i]=hexdec(substr($TheKey, ($i*2), 2));
}

/// Load input file into memory, PHP can handle large files (in the meg-o-bytes)
$buffer='';

while ( !feof(STDIN)) {
   $buffer .=  fgets(STDIN, 4096);
}

$ptr = strpos($buffer,"redshirt2");

if ($ptr >= 10) { // the text was detected too far from beginning, not a coded file
  $ptr=FALSE;
}

if ($ptr===FALSE) {
  $ptr=0; echo "redshirt2";
  $ENCODE=TRUE; $DECODE=FALSE;
} else {
  $ptr=$ptr+9; // len of "redshirt2"
  $ENCODE=FALSE; $DECODE=TRUE;
}

$keyindex=0;
for (;$ptr<strlen($buffer); $ptr++) {

  $char = ord(substr($buffer,$ptr,1));

  if ($char >= 33) {  // in range
    $keyindex = ($keyindex + 1 ) % KEYCONST;
    $shift = $keytable[$keyindex];

    $test0 = $shift - 33; // for calculating diff over 33
    $test1 = 128 - $shift;

    if ($test0 <  0 ) { $test0 =  0; }
    if ($test1 < 95 ) { $test1 = 95; }
   
    if ($DECODE) { // to decode, or not
      $char = ($char - $shift + 256) % 256; // 0-255

      if ( $char < 128  &&  $char >= $test1 ) { // overlapshift high
        $char = ($char + 128 - $test0 + 256) % 256; // floating upper range
      }
     
      if ($char < 33 ) { // && >= 0, overlapshift low
        $char += 95;
      }
    } // end of if DECODE

    if ($ENCODE) { // to encode, or not

      if ( $char < 128  &&  $char >= $test1 ) {
        $char -= 95; // overlapshift low prepare
      }

      $char = ($char + $shift) % 256; // 0-255

      if ( $char < 33 ) { // && >=0, shift high prepare
        $char = ($char - 128 + $test0 + 256) % 256;
      }
    } // end of ENCODE
  } // end of in range encode/decode

  echo chr($char);
}

?>
dx9s
level0
Posts: 4
Joined: Thu Jun 02, 2005 8:58 pm

PHP dual mode (update)

Postby dx9s » Mon Jun 06, 2005 7:24 pm

For those that either don't have PHP CLI (Command Line Interface) and only have the PHP CGI (Common Gateway Interface, a web server thing)..

I know this works on Win32 (XP) with the prebuilt PHP CGI package (4.3.11 win32 ZIP prebuilt) direct from the PHP website.

Make the changes...

*FROM*

Code: Select all

if (version_compare(phpversion(),'4.3.0','<')) { // otherwise manually open/close STDIN/STDOUT/STDERR
 define('STDIN',fopen("php://stdin","r"));
 define('STDOUT',fopen("php://stout","r"));
 define('STDERR',fopen("php://sterr","r"));
 register_shutdown_function(
   create_function( '' , 'fclose(STDIN); fclose(STOUT); fclose(STERR); return true;' )
 );
}

define('KEYCONST', 16); // much easier to change/alter/update
$TheKey = '1f0709010b0205050311280c23161b02';
$keytable = array();
for ($i=0;$i<KEYCONST;$i++) {
  $keytable[$i]=hexdec(substr($TheKey, ($i*2), 2));
}

/// Load input file into memory, PHP can handle large files (in the meg-o-bytes)
$buffer='';

while ( !feof(STDIN)) {
   $buffer .=  fgets(STDIN, 4096);
}




*TO*

Code: Select all

// STDIN/STDOUT/STDERR removed

define('KEYCONST', 16); // much easier to change/alter/update
$TheKey = '1f0709010b0205050311280c23161b02';
$keytable = array();
for ($i=0;$i<KEYCONST;$i++) {
  $keytable[$i]=hexdec(substr($TheKey, ($i*2), 2));
}

// the while loop reading STDIN, removed

$buffer = file_get_contents("in");



(assuming PHP CGI is in PATH)
Then run the CGI program from dos box in Win32 like this:

C:\somepath\> copy game.txt in
C:\somepath\> php -q redshirt2a.php < in > out

As the input file is now hard coded to be "in" from the current directory. Must use "-q" option to *quite* the CGI headers as really you are using PHP for command line purposes. CLI is a special build that allows certain command line stuff to occur (doesn't generate CGI headers for a webserver)

Using PHP CLI on linux spoils me a little bit!!

--Doug
Darksun
level5
level5
Posts: 6461
Joined: Sat Dec 07, 2002 7:08 pm
Location: 127.0.0.1

Postby Darksun » Tue Jun 07, 2005 8:49 am

Quadruple post! Is that a new record?
Evil Modder
level0
Posts: 2
Joined: Thu Aug 11, 2005 5:13 am

Postby Evil Modder » Fri Aug 12, 2005 6:52 am

Sorry to bump this, but i felt it better than making a new thread...

When I try to make this run in C++ (using MSVC++ 6.0) I get an Unknown Exception error.

Anyone know why, or better yet, have C++ code that works?

Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests