Ms=(({{1, #[[1]], #[[2]]}, {0, 1, #[[3]]}, {0, 0, 1}}))&/@Tuples[{0,1},3]

Ds = {(({{1, 0}, {0, 1}})),(({{-1, 0}, {0, 1}})),(({{-1, 0}, {0, -1}})),(({{1, 0}, {0, -1}})),(({{0, 1}, {1, 0}})),(({{0, -1}, {1, 0}})),(({{0, -1}, {-1, 0}})),(({{0, 1}, {-1, 0}}))}

MatrixForm/@Ms

MatrixForm/@Ds

ž[x_,y_]:=Mod[x.y,2]

Table[FirstPosition[Ms,Ms[[i]]~ž~ Ms[[j]]][[1]],{i,1,8},{j,1,8}]//TableForm

Table[FirstPosition[Ds,Ds[[i]].Ds[[j]]][[1]],{i,1,8},{j,1,8}]//TableForm