Given a ciphertext in RSA which is not comprime with our N, can we get the secret key? If we are given a ciphertext which is not coprime with our N (N = p*q), is there any way to get the secret key from this information in RSA?

I first thought you could divide the N by our ciphertext C, giving us a non-trivial factorization of N i.e. C * (N/C). But then we would be stuck trying to find $\phi(C)$ and $\phi(N/C)$, which I suppose is not easier than factoring N in the first place, if they are not primes. Can it be done?
Let $N=p\cdot q\quad,p,q\in\mathbb P$ be a semi-prime (as in RSA). Further let $a$ be any number for now. $$\gcd(a,N)$$ can now take exactly 4 values:


$\gcd(a,N)=1$
$\gcd(a,N)=p$
$\gcd(a,N)=q$
$\gcd(a,N)=N$


because there are no other factors of $N$ which could be the greatest common divisor.
Now let's take $c$ (your cipher text) instead of $a$. We can exclude case 1 because we know $c$ and $N$ are not co-prime (remember how co-prime is defined as $\gcd(a,b)=1$?). We can exclude case 4, because $c$ is an RSA ciphertext and thus was reduced $\bmod N$ before and this automatically ensures that $c&lt;N$. Furthermore $c$ is supposed to be a ciphertext for which the case $m=0$ probably happens with negligible probability and the only encryption that can yield $m=0$ is one of multiple (including 0) of the modulus, i.e. only 0, if we assume $m&lt;N$ as usual (which excludes the case where $m=0$ which would yield $\gcd(c,N)=N$)(thanks poncho and fgrieu). Also note that you don't need to bother with the key at all if $c=0$ because you directly know that $m=0$.

Now we're left with only two possible options: $p$ and $q$. So the $\gcd$ has to be one of that. And if we know one of the factors of $N$, everything else follows trivially.

Also note that "a and b are co-prime" is equivalent to $\gcd(a,b)&gt; 1$ and that this doesn't have to imply $a=k\cdot b$ for some k, because it may also be that $a=pq$ and $b=mp$ which would yield $\gcd(a,b)=p$. For a concrete example consider $a=10$ and $b=15$.