While Orat's solution in principle works, it is very inefficient, and I wouldn't want to give it as an example to my students. Instead, let me try to give a more efficient solution, which demonstrates that for computational algebra, you really should know and use both good algorithms, and powerful theorems.
AllPSubgroups := function(G, p)
local S, c, result;
S := SylowSubgroup(G, p);
result := [];
for c in ConjugacyClassesSubgroups(S) do
c := ConjugacyClassSubgroups(G, Representative(c));
Append(result, AsList(c));
od;
return Set(result);
end;
For example, on my laptop, for $PSL(3,3)$, this code take 0.34 seconds, while Orat's code takes 8.3 seconds.
The key idea is to exploit the Sylow theorems: Every $p$-subgroup is contained in a Sylow subgroup. Equivalently, if we take a fixed Sylow subgroup $S$, then every $p$-subgroup is conjugate to a subgroup of $S$.
Thus the above code first determines all subgroups of $S$, up to conjugacy. It then takes a representative of each such conjugacy class, and takes all conjugates of that in the original group. Note that we may see some $G$-conjugacy classes twice, since two subgroup $A$, $B$ of $S$ may be conjugate in $G$, but not conjugate in $S$. Hence we invoke Set
on the result before returning it.
One can do even better with some further tricks, if one really wants to. But in reality, for most questions one wants to answer, one would not optimize this code, but rather try to modify the question so that it e.g. suffices to know the conjugacy classes of $p$-subgroups, instead of explicitly enumerating the all. E.g. the number of 2-subgroups of $PSL(3,5)$ is 82926, but a Sylow 2-subgroup only has 22 conjugacy classes of subgroups; thus $PSL(3,5)$ has at most 22 conjugacy classes of 2-subgroups. It's much easier to answer questions about these 22 classes than about 82926 groups.
AllSubgroups
, as @Orat suggests below, has a big overhead since it really returns a list of ALL subgroups, and therefore is suitable only for toy examples. For larger groups, one should think in terms of conjugacy classes of subgroups and/or Sylow $p$-subgroups. E.g. you may calculate conjugacy classes of subgroups and then work only with those whose representatives are $p$-groups for some $p$. If you are interested only in a fixed $p$, then compute Sylow $p$-subgroup for this $p$, and then look at its subgroups, and at subgroups of its conjugates. – Olexandr Konovalov Jul 21 '15 at 20:42