The trick lives in the transfer logic: a whitelist that only permits the deployer to sell, a sell tax of 99%, a maximum transaction size set to nothing, or a blacklist applied to buyers after they enter. Price only rises, because selling is impossible.
Detection tools simulate a buy and an immediate sell and report whether it succeeds, and they catch the crude versions. More sophisticated contracts behave normally until a threshold or a timer flips, so a clean simulation is not proof.
Basic defences: read the contract on a block-explorer, check whether the owner has renounced, prefer verified source, treat any token you did not go looking for as bait, and use a burner-wallet with tiny size for anything speculative. Assume total loss is the base case on unknown tokens.
Related: rug-pull, soft-rug, wallet-drainer, token-blacklist-function