A straightforward method that reduces the problem to a standard Rational Roots Theorem problem, is given here. We start with reducing the polynomial modulo the polynomial $x^2 - p x - q$, this yields:
$$(p^3+6 p^2+2 p q-9 p+6 q-162) x + p^2 q+6 p q+q^2-9 q-243 \tag{1}$$
Then we need to find integers $p$ and $q$ such that this expression is identical zero. Putting $x = -\frac{q}{p}$ and solving for $p$ yields:
$$p = -\frac{6 q\left(q-27\right)}{q^2+243}\tag{2}$$
This then sets one linear combination of the two coefficents in (1) zero. We need to set another one to zero. We can take the constant term and use use (2) s to eliminate $p$. This yields:
$$q^6-9 q^5-729 q^4+13122 q^3+177147 q^2-531441 q-14348907 = 0\tag{3}$$
The problem has now become a straightforward application of the Rational Roots Theorem. The constant term is $-14348907 = -3^{15}$ So, we know that $q$ has to be a power of $3$ up to a sign. If we substitute $q = 2 + t$, then we get a polynomial equation in $t$ which has a constant term equal to the r.h.s. of (3) for $q = 2$, which is $-14610113$ this has prime factors of $7$, $29$ and $71971$. Adding 2 to these possible solutions yields the corresponding value for $q$, but this has to be a power of $3$ up to a sign. This means that $q=9$ and $q = -27$ are the only possible solutions.
Inserting $q = 9$ in (2) gives $p = 3$, while inserting $q = -27$ in (2) gives $p = -9$. The quadratic factors $x^2 - p x - q$ are thus $x^2 -3 x - 9$ and $x^2 + 9 x + 27$